oxxxo Posted May 4, 2015 Share Posted May 4, 2015 I am trying to change the color of the sprite using tint, however after certain milliseconds the color will go back to its original color,My goal is just to let the user know that there is a color change at some moment.var button = this.add.sprite(10, 750, this.drawButtons(0, 0, 160, 160, 20, "yellow" )); button.inputEnabled = true;function returnColor(){ button.tint = 0xffff33;}function changeColor () { button.tint = 0xff0000; this.time.events.add(50, this.check, this).autoDestroy = true;; }function update() { this.button.events.onInputDown.addOnce(changeColor, this);}the timer actually works, however the longer you are on the game the longer the color change responds.. it seems like the timer event is adding up the time.. what is the right way to implement this? Link to comment Share on other sites More sharing options...
lukaMis Posted May 4, 2015 Share Posted May 4, 2015 Do not add your event handler in update method. (You are adding event listener for the same event every update!) Link to comment Share on other sites More sharing options...
Recommended Posts