Search the Community
Showing results for tags 'activePointer'.
-
Hi everyone. I'm playing around with TypeScript and Phaser for the first time. I started off with plain Javascript/Phaser in Sublime and got a little game going where I could move a sprite around the screen and click to shoot. It worked relatively easily which was nice. Then I decided to switch to TypeScript and Visual Studio because intellisense and the class/inheritance syntax looked like it would make things easier. I still have hope, but I've run into some problems. The first issue that came up was setting up WASD controls with AddKey. I tried to use the recommended var movementLeftKey: Phaser.Key = game.input.keyboard.addKey(Phaser.KeyCode.A);but I got the message: Property 'KeyCode' does not exist on 'typeof Phaser' I got around it by using var movementLeftKey: Phaser.Key = game.input.keyboard.addKey(Phaser.Keyboard.A)This made me think that I was using the wrong version of phaser files since 2.4.4 ought to allow KeyCode. Unless I'm doing something wrong(certainly possible), I believe I'm all up to date. I have p2.d.ts, phaser.d.ts, phaser.js, phaser.min.js, and pixi.comments.d.ts from https://github.com/photonstorm/phaser/tree/master/typescript all in my project as recommended in the typescript tutorial: http://phaser.io/tutorials/how-to-use-phaser-with-typescript I wanted to use phaser.comments.d.ts instead of phaser.d.ts, but it looks like it hasn't been updated - the version appears to be 2.4.3 rather than 2.4.4 Another issue is with detecting mouse clicks. Before typescript/visual studio, I used game.input.activePointer.leftButton.isDown to check if the player was clicking. Visual Studio won't even compile that because it says game.input.activePointer.leftButton is a boolean. All of the Phaser documentation says it's a DeviceButton, and I've even printed out the value with console.log and it says it's an [object Object], so definitely not a boolean. Any ideas why Visual Studio thinks otherwise? I am using the most recent version of typescript that came installed with Visual Studio 2015 Community. Here's my project on Github. I haven't ever used github before so if something appears messed up with how I uploaded it, that's why and please let me know. The code dealing with mouse and keyboard input is here. Thanks in advance for any advice.
- 2 replies
-
- typescript
- activePointer
-
(and 6 more)
Tagged with:
-
I don't know why this is happening but the getGold() function inside the this.input.activePointer.isDown is not working on mobile but working fine on browsers. I compiled the code using cordova/phonegap to put it on mobile. What should happen: player tap and hold on the screen > animation should play > everytime it hits the last frame it should get gold What's happening (browser): player taps and hold on screen > animation plays > everytime it hits the last frame it gets gold What's happening (mobile): player taps and hold on screen > animation plays Code: function update() {if(this.input.activePointer.isDown) { player.animations.play('mine'); var curframe = player.animations.currentAnim.frame; if(curframe == 3) { getGold(function() { var convertedScore = (score / 3.0864716706).toFixed(3); if(convertedScore == 100) { showAlert("CONGRATULATIONS! \nYOU REACHED THE \nGOAL of 100 CARAT!"); } }); }} else { player.animations.stop(); player.frame = 0;}}function getGold(callback) { score = score + (Math.floor(Math.random() * maxgoldpersec) + mingoldpersec); var convertedScore = (score / 3.0864716706).toFixed(3); scoreText.text = "Gold: " + convertedScore + ' carat'; if(callback) { callback(); }}
-
Whatever I try, game.input.activePointer.movementX and game.input.activePointer.movementY always returns 0. Am I wrong to assume that they should return the distance the pointer has moved since the last frame? rawMovementX & Y does the same thing by the way. Any solution, have I forgot to enable something? Docs are not to much help on this one.
- 2 replies
-
- input
- activePointer
-
(and 2 more)
Tagged with: