Jump to content

tween.onComplete delete the correct sprite


Zackorz
 Share

Recommended Posts

I use tweens for my movement of sprite objects. These sprites are generated randomly and getting pushed into an array.

 

When the sprite movement has finnished, i want to destroy them and removed also their position in the array.

 

Im trying to do it with the "onComplete" function but i dont know how i can figure out which sprite has finished his movement and can be deleted.

 

Is it possible to get some feedback from "onComplete" that tells me which sprite has "completed" his movement ?

Link to comment
Share on other sites

Wherever it is that you start the tween you have reference to the sprite, right? Because it's the sprite that you're tweening? Phaser signals can take args like this:

// enemy1 is the sprite you care about...
game.add.tween(enemy1).to(...).onComplete.add(this.handleOnComplete, this, null, enemy1);

enemy1 will be passed as the first and only argument to this.handleOnComplete.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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