Sprite object is not destroyed properly

  • Problem Description

    Destroying last object in the StartOfLayout event (also tried keyboard events, same) will not destroy the object properly.

    Attach a Capx

    [attachment=0:1av3ge2d][/attachment:1av3ge2d]

    Description of Capx

    Destroys last instance of object type "A" and creates new one. After that tries to move only instance of type "B" next to type "A".

    Steps to Reproduce Bug

    • Run the capx, and you will see it is working as expected.
    • After that, disable the "Wait 0 second" action and run it again.

    Observed Result

    B will be moved next to first instance of A (which supposed to be destroyed).

    (first instance of A is not visible anymore)

    Expected Result

    First instance of A must be destroyed, and B must be move next to newly created instance of A without using "Wait 0 second" action.

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (YES)
    • Node-Webkit: (YES)

    Operating System and Service Pack

    Windows 8.1 x64 with latets updates.

    Construct 2 Version ID

    Construct 2 182 Beta

  • Closing as won't fix. Firstly 'Destroy' doesn't immediately destroy the object; it is flagged to be removed at the end of the next top-level event, so will continue to exist available for picking in subevents. Secondly 'Create object' does not really fully create the object until the end of the next top-level event, and it cannot be re-picked using "pick all" in sub-events until the end of the next top-level event. 'Create object' does however pick the object that is created, so if you set B's position immediately after the create action and just delete the sub-event it works.

    The fact objects don't really create or destroy until the end of the next top-level event is an architectural limitation and it could not be worked around without great difficulty.

  • Firstly 'Destroy' doesn't immediately destroy the object; it is flagged to be removed at the end of the next top-level event, so will continue to exist available for picking in subevents. Secondly 'Create object' does not really fully create the object until the end of the next top-level event, and it cannot be re-picked using "pick all" in sub-events until the end of the next top-level event. 'Create object' does however pick the object that is created, so if you set B's position immediately after the create action and just delete the sub-event it works.

    The fact objects don't really create or destroy until the end of the next top-level event is an architectural limitation and it could not be worked around without great difficulty.

    Ashley , I'm an avid manual user, I think I never came across this explanation and this is actually the first time I understand it properly. I would like to request this statement to be included into the manual under "How Events Work".

  • Yes, it would be great. Because sometimes C2's event system puzzles me.

  • DuckfaceNinja

    good poinht becuase many times i have spent scratching my head when i ghet stuck with something and now it turns out it was becuase of this... this should be in the manual

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How things work are usually intuitive for a coder to understand, but when it comes to non-coder like me, there are a lot of things that are non-intuitive, I rely heavily on the manual whenever my events doesn't work. The manual is a great tool during debugging in which you can counter-check the description whether your events is actually compliance to how things work. I'm sure there are more "manual material" that went unrecorded because it lays on the abyss of the forum, it needs somebody to point it out.

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