Changing Layout will create objects on the next layout

Bugs will be moved here once resolved.

Post » Fri Dec 19, 2014 3:55 am

I came across this issue I was having again, after noticing it over a year ago: request-destroy-all-sprites-action_t80832

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:
Image

This also seems to cause issues when I return to the layout:
Nodewebkit:
Image

Chrome:
Image

Firefox:
Image


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:
Image
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.

____________________________________________

Summary: 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: https://copy.com/gRmijhp1JWJb7Qkz/bug_c ... download=1
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)
Last edited by alspal on Sat Jan 10, 2015 10:48 am, edited 1 time in total.
B
147
S
74
G
20
Posts: 1,786
Reputation: 22,527

Post » Sat Dec 20, 2014 6:37 pm

It doesn't sound like that's the way it would work but it sure seems to happen in the example.

To drive it home, disable event 1. Where all blocks are destroyed, one is created.

Work around is to put a destroy in "on start of layout"
(which, now that I think about it, I seem to remember doing with Chicks on Trampolines...)
B
230
S
62
G
33
Posts: 902
Reputation: 40,319

Post » Tue Dec 23, 2014 1:01 am

Thanks for confirming that it's not just me!

I think I'll just wait for the fix, bug workarounds end up making things messy in a large project.
B
147
S
74
G
20
Posts: 1,786
Reputation: 22,527

Post » Tue Dec 23, 2014 2:34 pm

the "on destroyed" is a trigger, it will fire when the instances are destroyed, this happens just before the layout ends (so using an "on end of layout:destroy" may work), IIRC it has already been reported but was closed as wontfix, but that could change.

other workaround that is cleaner:having a variable that changes just before you ask for a layout change, the value of the variable influencing if the "on destroyed" will work.

Still hoping for a definite fix.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Tue Dec 23, 2014 11:15 pm

Aphrodite wrote: IIRC it has already been reported but was closed as wontfix


That's a bit odd?

Currently for me a it's a game breaking bug, on none of my event sheets have I told it to create objects on a different layout, but it's doing it anyway.
B
147
S
74
G
20
Posts: 1,786
Reputation: 22,527

Post » Wed Dec 24, 2014 9:29 am

I reported it before and it's come up a couple of times since then but it's working as intended.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Thu Dec 25, 2014 5:44 am

Thanks for showing that closed report, I still desire an understanding of the logic though. To me it doesn't seem right to still create objects on the next layout, as I never told it to do that.

To me the best way would be to finish running the event sheet (which includes finishing the trigger events, so basically stopping the sheet) THEN destroy all objects and change layout.
B
147
S
74
G
20
Posts: 1,786
Reputation: 22,527

Post » Sun Dec 28, 2014 12:45 am

alspal wrote:To me the best way would be to finish running the event sheet (which includes finishing the trigger events, so basically stopping the sheet) THEN destroy all objects and change layout.


Definately makes sense to me as well.

Since it is not classed as a bug, maybe it would make a good feature request.....
If it can be done, someone on the web will show you how to do it!

CDASI Games Mentality Break Splat-a-bug FlapFleet Challenge
B
34
S
12
G
7
Posts: 358
Reputation: 7,148

Post » Mon Dec 29, 2014 9:51 am

If C2 insists on that logic,then we will have to follow that logic.
You do not have the required permissions to view the files attached to this post.
B
17
S
4
G
1
Posts: 203
Reputation: 1,583

Post » Mon Dec 29, 2014 4:50 pm

Have you tried adding wait(0) before changing layout ?
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 5 guests