The "On Destroy" trigger is called on the object when on layout change.
I can see situations where that would be usefull (like saving some enemies position, though a "On Layout Change" + foreach Enemies would be cleaner)
But in general, you don't really want the "On Destroy" to trigger. Personnally I often use it to trigger special fx like explosion graphics and sounds.
So if you implement an in game pause with an "Exit to Main Menu" button, you'll see and hear the fx when going back to the menu because of this "On Destroy"
I would expect either:
- the "On Destroy" to only happen when a destroy action is performed on the object,
- or, to have the choice of the two behaviors with an extra parameter to "On Destroy". Like "On Destroy ignore layout change (yes/no)"
Also, the current behavior is a bit inconsistent since it happens on layout change but not on layout restart, though I'd expect the object to be destroyed and recreated.
Attach a Capx
Description of Capx
Start the preview and just left click to change layout. You'll se the explosion generated by the destruction of the Sprite.
To see the expected result, disable the "Problem" group and enable the "Work Around" group
Steps to Reproduce Bug
The explosion is played on Layout 2
Nothing should happen on Layout 2
- Chrome: (YES)
- FireFox: (YES)
- Internet Explorer: (YES)
Operating System and Service Pack
Windows 7 SP1
Construct 2 Version ID