dasneko Posted March 26, 2015 Share Posted March 26, 2015 I want to make a code where if you hold down the spacebar key, it will charge up and shoot with that amount of power on its release. //charging power if (this.fireButton.isDown) { this.power += 5; } this.fireButton.onUpCallBack = function() { console.log("hi") //fire function };where this.fireButton = this.cursors = this.input.keyboard.createCursorKeys(); this.fireButton = this.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);Everything work great beside the fact that onUpCallback doesn't work and I am looking for the one that does. Thank you very much! Link to comment Share on other sites More sharing options...
dasneko Posted March 26, 2015 Author Share Posted March 26, 2015 //charging power if (this.fireButton.isDown) { this.power += 5; firing = true; } if (this.fireButton.isUp) { if (firing == true) { console.log("hi"); firing = false; } }Got something like this working but still looking for a better solution. Link to comment Share on other sites More sharing options...
dasneko Posted March 26, 2015 Author Share Posted March 26, 2015 if (this.fireButton.isDown) { this.power += 5; this.fireButton.onUp.add(this.fire, this); }@rich got me a solution. Closed. dasneko 1 Link to comment Share on other sites More sharing options...
Recommended Posts