Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

pendingDestroy doesn't work on killed objects

Andrey Denisov

Recommended Posts

I faced the following problem.

I have a sprite, which is a part of Phaser.Group. When I kill the sprite using a "kill" method and then mark it with the "pendingDestroy = true;", the sprite is not being destroyed at all.

If I understand the idea of using "pendingUpdate" the game engine must destroy the object automatically in "preUpdate" method. I checked that the Phaser.Group calls for the "preUpdate" method of its children even if they are not alive.

However, the "preUpdate" method of the Phaser.Sprite class seems to be very tricky.


This pendignDestroy is processed only in Phaser.Component.Core.preUpdate, so if one of the functions listen in line 49139 returns false the pendingUpdate won't be processed. Unfortunately, this is exactly what the first method does (Phaser.Component.PhysicsBody.preUpdate).


For non existing sprites (i.e. killed sprites) preUpdatePhysics() will always return false. Hence, the pendingDestroy  flag won't be processed in Phaser.Component.Core.preUpdate.



P.S.  I can't use the "destroy" method directly. For example, when I check for collisions between two groups with more than one alive object in each group, destroying objects can cause some errors (still trying to find out the reason of it).

Link to comment
Share on other sites


  • Recently Browsing   0 members

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