Jump to content

kill a tween only if the tween exist ???


espace
 Share

Recommended Posts

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

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...