espace Posted February 5, 2017 Share Posted February 5, 2017 hi, i have this tween: this.tween_repulse_to_right = game.add.tween(this).to({x:this.x+200,y:h2+25},this.time_repulse,Phaser.Easing.Linear.None,true,0) and i want to do this only if the tween exist : this.tween_repulse_to_right.stop() is a special snippet without flag to do this ? Link to comment Share on other sites More sharing options...
head Posted February 5, 2017 Share Posted February 5, 2017 If I get it right, there are several ways come to mind: 1. check if it is defined if (typeof this.tween_repulse_to_right != 'undefined') { 2. check if it's a tween (requires it to be defined with any value) if (typeof this.tween_repulse_to_right == Phaser.Tween) { 3. the simpliest way if (this.tween_repulse_to_right) { Link to comment Share on other sites More sharing options...
mwissink Posted February 6, 2017 Share Posted February 6, 2017 if (this.tween_repulse_to_right) { this.tween_repulse_to_right.stop() } if this.tween_repulse_to_right isn't defined, this.tween_repulse_to_right should be undefined - making conditional should be false. But if it is defined, the conditional will be true. Hopefully this is what you need. Link to comment Share on other sites More sharing options...
Recommended Posts