I came across this issue I was having again, after noticing it over a year ago:
I think sprites are created (every browser/node) when changing layout. This means sprites are created on the next layout you go to. What's the logic you're using when you use the "go to layout" action? Because the way it seems to be working for me is this: When it gets the event "go to layout" all instances are destroyed, then it continues to run the rest of the sheet (or just the triggers?), if you had any "on destroyed" events or "create object" actions that were going to run that that tick then they'll be created — but on the next layout.
This causes issues for me, you can see here that after "go to blank layout" it has some newly created sprites? The layout should be completely black, but it's not, it has objects that were created from the previous layout:
This also seems to cause issues when I return to the layout:
I originally thought that objects were simply lingering from layout to layout, but since realizing that they were most likely newly created I then tried disabling a group that was creating most of these objects before I used the go to layout action:
Disabling that group, which I use to mostly create things, seems to have solved the issue of objects from one layout moving to another layout and I now get a nice black screen when going to my blank layout. It also removed the above errors from occurring.
Objects are probably destroyed by the "go to layout" action is performed but then events that use "on destroyed" are still run afterwards. This should not be the case as it means objects will be created on the next layout you go to.
Here is a CAPX:
You'll notice that after 2 seconds, it will change to a black blank layout, and an object from the previous layout will be on the next layout (when it shouldn't be there).
I'm guessing this is something like what you're currently doing for the tick?:
- Change layout action is noticed
- Automatically destroy every object
- Layout is changed
- Continue running the event sheet for that tick (which may include creating objects, that are then placed on the new layout)