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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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