Sprite instances persist after destroy

0 favourites
  • 5 posts
From the Asset Store
A set of 10 pixel art animated magic effects with icons. 2 Fire, 2 Earth, 2 Wind, 2 Water, Portal, Explosion.
  • Hi, manual states that events/actions run in order shown but some actions (Sprite.Destroy) seem to occur only after end of main loop.

    (also trying to analyse this I got an oddly similar result when setting a global variable).

    Link to .capx file (required!):

    dl.dropboxusercontent.com/u/15657176/Destroy_Order.capx

    Steps to reproduce:

    1. Run prog

    2. Click on a sprite (sprite is destroyed)

    Observed result:

    1. Note that Destroyed Sprite UID still appears in For Each Sprite report

    2. Note also that although 'Clicked' is set to YES the "BEFORE" (before loop end) report (which is after the click event) does not get shown.

    Expected result:

    1. Destroyed Sprite UID should not be in For Each report

    2. "BEFORE" report should be showing

    3. "AFTER" (after loop end) is as expected

    Browsers affected:

    Chrome: yes

    Firefox: ?

    Internet Explorer: ?

    Operating system & service pack:

    Win 7 SP1

    Construct 2 version:

    r143

  • Closing: this is in fact by design. Objects are only marked to be destroyed by the 'Destroy' action, and are in fact truly removed only at the end of the next top-level event. This is for two reasons:

    1) it's a useful feature: sequences like "Destroy sprite"; "Create explosion at Sprite.X, Sprite.Y" in fact work when it would not if the sprite was truly destroyed immediately

    2) the architecture of the engine requires that objects are not truly destroyed mid-event, because it may still be picked by conditions in parent events that still reference it.

  • Hi,

    Suspected as much. However, if this is expected behavior, then surely it should be documented (otherwise I would not have reported it).

    I had a good search through the manual and could not find anything explaining this (although I found at least one occurrence of the manual distinctly saying instructions are applied in order, whereas "destroy" is clearly not).

    Please could you also suggest why, having set the variable Clicked to YES, the next event that checks if Clicked is YES does not get run.

    Thanks for the swift action on this,

    RR

  • Triggers fire outside of the event loop. So when 'On left button clicked' fires, it's not currently running the event sheet - the next tick it will run the event sheet from the top, so the next event that runs after the click event is event 1, not event 7.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)