Problem Description
I got objects that spawn other objects when they are destroyed. For example, explosion after grenade, monsters that spawn smaller monsters upon death, etc. I spawn these objects in "On Destroyed" event, and I see that when I change the layout, the objects spawned during "On Destroyed" will appear in the next layout.
Attach a Capx
https://www.mediafire.com/?htk7sn6if1vhduk
Description of Capx
The capx has a black box and a red box.
The black box got a drag and drop behavior. Left click to move it around.
Middle click on black box to destroy it, which will leave a red box behind. (using "On Destroyed" event, apparently)
Right click creates another black box.
Press R to restart layout. You will see that upon restart, red boxes will appear in all positions of where all the black boxes were.
Steps to Reproduce Bug
Just create objects during "On Destroyed" event and change layout, and you will see this bug.
Expected Result
Objects that are created in "On Destroyed" event should not appear in the next layout.
Affected Browsers
Operating System and Service Pack
Win7 64 bits
Construct 2 Version ID
r173 64bits
I used "On Destroyed" in various places: a big slime monster could spawn more smaller slime monsters upon death, and smaller slime monsters also spawn the liquid explosive upon death. The liquid explosive leaves trace of liquid upon destroyed. Everything is fine if the player killed everything and nothing invokes "On Destroyed" event upon layout changing, but if some objects are not killed, something will pop up in the next layout. That's bad.
One more thing: I also noticed that sometimes the object count becomes negative/incorrect in the game I am developing. During layout changing, the game stutters a bit, given there are hundreds of objects in the layout. And sometimes, the object count is incorrect.
I have been trying to reproduce the negative object count on a smaller scale capx, but I couldn't reproduce it. All these "On Destroyed" events in my project also have sound effects played during "On Destroyed" and they stutter quite a bit upon layout changing. I am not sure whether frame stuttering is related to negative object count or not. Yet I only see object count becoming incorrect upon layout changing (ie. restart layout) only. In fact, by simply restarting a layout in my project once or twice, I already see object count number decreasing upon restart. Sometimes I see it on the first restart, sometimes on the second, sometimes third.
I have also tried remove "included event sheets" that are related to these events of monsters, etc., and I see that the object count number is correct. But like I said, I couldn't reproduce this on a smaller scale yet. Still, could you please investigate what could go wrong here? Thank you.