totallybueno Posted April 21, 2014 Share Posted April 21, 2014 Hi there guys, I´m having a weird (at least for me) problem in my game...I´m gonna explain it: I have a ball and I have to wait for the user to click that ball to launch a tween This is the code I have//ACTIVATE THE BALLthis.ball.inputEnabled = true;this.ball.events.onInputUp.addOnce(this.shootBall, this); and in the functionthis.ball.inputEnabled = false;this.ball.events.onInputDown.remove(this.shootBall, this);var myIndex= Math.floor(Math.random()*(arrayXFakes.length-1));this.exitTween= this.game.add.tween(this.balon).to( { x:arrayXFakes[myIndex], y:arrayYFakes[myIndex] }, exitTime/2, Phaser.Easing.Linear.None).to({ y: 750 }, exitTime*2, Phaser.Easing.Linear.None).start();The problem is that if I double click onto the sprite, I have really weird effects... with addOnce the listener is running exactly that, once, but it seems that the tween is starting twice, something really weird, actually I think that even my explanation is pretty weird... Anyway, something wrong to you guys in this code? Link to comment Share on other sites More sharing options...
Pedro Alpera Posted April 22, 2014 Share Posted April 22, 2014 Try something like this: shootBall: function(item) { console.log("shoot!"); item.inputEnabled = false; this.game.add.tween(item).to({x: 300, y: 300}, 400, Phaser.Easing.Back.Out, true); } Link to comment Share on other sites More sharing options...
Recommended Posts