linkers Posted July 14, 2016 Share Posted July 14, 2016 Good day, I was trying to modify the example code below, to load up power and fire with mouse. The load up is working great, but there seems to be some issues when im calling the function fire() from mousePointer.isUp. This is the code I currently have, it seems to be executing only once, than it freezes up, it stops loading new powersettings, but the moving functions seem to be working fine! if (this.input.mousePointer.isDown && this.power > 0 && this.power < 50) { this.power += 1; this.loaded = true; console.log(this.power); } else if (this.power == 50){ this.power = 50; this.loaded = true; } else { this.power = 1; } if (this.input.mousePointer.isUp && this.power > 0 && this.power < 51 && this.loaded) { this.loaded = false; this.fire(); //this.add(this.fire, this); this.power = 1; } Example codes. http://codepen.io/photonstorm/pen/gbgvpM?editors=001 this.fireButton = this.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); this.fireButton.onDown.add(this.fire, this); Link to comment Share on other sites More sharing options...
Recommended Posts