Jump to content

can I stop sprite update when it been killed


scofieldly
 Share

Recommended Posts

Hi guys, 

I want to make a sprite pool for make bullet in the game, 

when I kill the bullet sprite, I found the update function is still running, so I wonder is there any way to stop the update function, actually I want to make a new update function when I get it from the pool. thanks.

Link to comment
Share on other sites

If the same bullet is not going to be re-used again later, it should be removed from the game using destroy() instead of kill(). This will remove the bullet from the game, which would definitely stop the updating.

To answer your question directly, though, in your update function, you can check the bullet's sprite for its alive property before running its update. All kill() does is set a few booleans to false so the sprite will stop displaying, not remove anything: Sprite.kill() docs

Link to comment
Share on other sites

On 2016/11/2 at 9:13 PM, Alamantus said:

If the same bullet is not going to be re-used again later, it should be removed from the game using destroy() instead of kill(). This will remove the bullet from the game, which would definitely stop the updating.

To answer your question directly, though, in your update function, you can check the bullet's sprite for its alive property before running its update. All kill() does is set a few booleans to false so the sprite will stop displaying, not remove anything: Sprite.kill() docs

thanks alamantus

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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