Jump to content

Is there any way to easily 'clean up' a sprite from references, before using Destroy() on it?


Grandy12
 Share

Recommended Posts

Well, if the enemy is dead why are you still trying to read it's position?

 

There's a function on update that keeps tabs of the position of all sprites inside the group called 'enemies', to simulate a behavior. Like, if their position.x is too far away from the player's position.x, they attempt to shorten the distance, or if it is too close, they try to back away. So it's not really me that wants to read its position, it's just that I told the game to keep reading it's position all the time.

 

 

But your post gave me an idea, which worked.

 

I just added another boolean to the sprite to check if it was dead or not, then I had that position checked stop checking any sprites where it was set true, and afterwards destroyed it.

 

I mean, in retrospect that was pretty simple, and I feel rather silly.

 

Thanks for helping my figure this out.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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