[Fixed] Weird visual glitch when setting scene to current scene

First of, sorry for asking so many questions but I really don’t get this one. (I’ll try to answer some questions myselfe if I can)

I create shadows for all sprites in a certain group. I do this by for each → create shadow (transparent sprite) at object.X()+5 object.Y()+5. Then I set the ZOrder of the shadow to -1
However, I have a reset button in my game and when the player presses it I set the scene to the current scene.

When I do this everything appears normal but the shadows flash in the wrong position for 1 frame. I would say around object.X() + ~100.
I also have a ‘loaded’ variable to make sure that the shadows are only loaded once whenever I enter the scene. The camere remains at 0,0 at all times, except for when the level is beaten.

The player also has the option to replay the level after he beat it (still in the same scene but with a different camera position) and when I restart here, or enter the level from the menu, this doesn’t happen.

What is going on here? I tried changing the order of the relevant events around already.

I don’t really know, but exactly this kind of things are why loading screens exists! They are actually just a sort of Sprite displaying over everything to hide such glitches that happens while the scene still loads/executes instructions to initiate the scene.

1 Like

maybe do a costum behavior for the shadow, and do the “doStepPreEvents”, so it loads the shadows first?

1 Like

Using a loading screen looks just as glitchy, because it loads pretty much instantly.

Thanks, but how exactly would that work? The shadows don’t exist pre Events. I think I could create them from the objects behavoir that ‘casts’ them?
I just included the shadows in the image and changed the hitboxes for now.
What I don’t understand is: the shadows shouldn’t ever exist in a different position in the first place, because I create them at X+5, Y+5.

Are you using any external layouts?
Sounds similar to this bug:

That sounds like what I am experiencing. But I don’t use external layouts.

Yep, if you create objects at the beginning of the scene, you get the same glitch.
I’ll also mention this on GitHub.