Search the Community
Showing results for tags 'hotkeys'.
-
Greetings, I was looking the forum for an answer, but wasn't able to find even the issue. Maybe it's just my wrong usage of Phaser mechanics. Anyway, I'll be gratefull for any information. The matter: I got two separate files ("game.js" and "player.js"). While game.js used as a "state", player.js is just an attached library with some functions. There is hotkey binding in player.js, which is called in game.js within "update" property. You know, to make an object move around. But when the hotkey is pressed, there are from 60 to 150 identical assignments happens. It is about 100 times more on the average than is needed. Question: Is there a solution to make just one assignment? Additional information: I'll try to explain the whole structure in few words. In "game.js" there is variable with object ePow = { x: 100*(settable int), y: 100*(settable int), currentX: 0, currentY: 0 } It is called within "creaton" property of game.js from player.js's another prototype, but I think it isn't important. In "player.js" there is prototype "keybind", which contains creation of hotkeys, listeners for hotkeys and assignment functions. Points of interest within keybind: 1. this.(game.js's context with sprite object).velocity.x = (game.js's context).ePow.currentX; 2. function thrustLeft () { (game.js's context).ePow.currentX = (game.js's context).ePow.x * -1; 3. this.(hotkey).onDown.addOnce(thrustLeft); When hotkeys is pressed console shows me, that value was assignet for 127 times, for example. Help