SYNYST3R1 Posted October 14, 2013 Share Posted October 14, 2013 Like how Unity has getMouseButton and getMouseButtonDown. Is there something like getMouseButtonDown which doesn't return true again until I release the mouse and click again? Right now I am using game.input.mousePointer.isDown which is true as long as I am holding it down and I only want it to be true once. Link to comment Share on other sites More sharing options...
rich Posted October 14, 2013 Share Posted October 14, 2013 game.input.onDown.add(doSomething, this); function doSomething() { // will only ever be called once, when the the input is down } Link to comment Share on other sites More sharing options...
SYNYST3R1 Posted October 14, 2013 Author Share Posted October 14, 2013 Thank you, that is exactly what I needed. Link to comment Share on other sites More sharing options...
SYNYST3R1 Posted October 15, 2013 Author Share Posted October 15, 2013 Idk if this warrants another post or not. How do you use onKeyDown and with a specific key? Link to comment Share on other sites More sharing options...
Hsaka Posted October 15, 2013 Share Posted October 15, 2013 The input examples folder shows some ways of doing this: https://github.com/photonstorm/phaser/tree/dev/examples/inputupKey = game.input.keyboard.addKey(Phaser.Keyboard.UP);if (upKey.isDown) {} Link to comment Share on other sites More sharing options...
SYNYST3R1 Posted October 15, 2013 Author Share Posted October 15, 2013 isDown will continually call whatever I have in the if statement. I only want to call it once each key press. Link to comment Share on other sites More sharing options...
rich Posted October 15, 2013 Share Posted October 15, 2013 upKey = game.input.keyboard.addKey(Phaser.Keyboard.UP); upKey.onDown.add(doSomething, this); function doSomething() { ... } Link to comment Share on other sites More sharing options...
SYNYST3R1 Posted October 15, 2013 Author Share Posted October 15, 2013 I get an error whenever I try that Object #<Object> has no method 'addKey' Link to comment Share on other sites More sharing options...
rich Posted October 15, 2013 Share Posted October 15, 2013 It's in the dev branch only at the moment. Link to comment Share on other sites More sharing options...
SYNYST3R1 Posted October 15, 2013 Author Share Posted October 15, 2013 Still getting same error after getting the dev branch and an error from my animations now Cannot read property 'index' of null Link to comment Share on other sites More sharing options...
rich Posted October 15, 2013 Share Posted October 15, 2013 Don't use the phaser.js from the build folder, use the source (Luke ) Link to comment Share on other sites More sharing options...
SYNYST3R1 Posted October 15, 2013 Author Share Posted October 15, 2013 Blah now PIXI is not defined. I am completely oblivious when it comes to javascript, so sorry for all the problems. Link to comment Share on other sites More sharing options...
rich Posted October 15, 2013 Share Posted October 15, 2013 Heh, oh man. Ok look here you go: https://dl.dropboxusercontent.com/u/182996/phaser.js This is a single-file version of Phaser, built about 5 minutes ago, so is all you need to include in your game (along with your source code of course). Note that a LOT has changed between the current live version and this one. Link to comment Share on other sites More sharing options...
SYNYST3R1 Posted October 15, 2013 Author Share Posted October 15, 2013 Now I get Cannot read property 'uuid' of nullCannot read property 'onDown' of undefined Link to comment Share on other sites More sharing options...
rich Posted October 15, 2013 Share Posted October 15, 2013 Yes like I said, stuff has changed. I expect it's the way you're creating an animation, but it's impossible to know without seeing code. Link to comment Share on other sites More sharing options...
SYNYST3R1 Posted October 15, 2013 Author Share Posted October 15, 2013 player.animations.add('walkDown', [0, 1, 2, 3], 10, true, false);Figured out the error for onDown by myself, but still not sure what is different with the animations Link to comment Share on other sites More sharing options...
rich Posted October 15, 2013 Share Posted October 15, 2013 Ah the issue is that you've got the "useNumericIndexes" flag set to false, but in your case you are using them. So either set the last parameter to 'true' or just don't include it at all, as it detects you're using an array of numbers automatically now anyway. Link to comment Share on other sites More sharing options...
SYNYST3R1 Posted October 15, 2013 Author Share Posted October 15, 2013 Removing it didn't work, but setting to true it works perfectly now. Link to comment Share on other sites More sharing options...
Recommended Posts