Fade in scene change collection problem

The bigger problem I am having today is about doing a fade out between scenes.

My default collection (called “loader”) has a black image that fills the screen. It becomes opaque just before a new scene is loaded, and then fades out once the proxy loaded message is received. It works perfectly in all my scenes. However, in my levels, I have an object (called “tile”) that has this in the init:

function init(self)
local p= go.get_position()
local oddeven= ((p.y+p.x)/100)%2 --sets to 1 or 0 to change tile colour
go.set("#sprite", "tint.w", oddeven) -- sets tile colour to A or B (a checkerboard effec)
local objp= go.get_position()
p.y = p.y-500 -- sets start point for sliding up
go.set_position(p) -- goes to start point before sliding up
local time=((p.x*4)+(1400-(p.y*4)))/5000
go.animate(".", "position", go.PLAYBACK_ONCE_FORWARD, objp, go.EASING_OUTBACK, time) --slides up
end

This object jumps forward to the top of the Z layer for a tiny split second (over the top of the black image). However, if i print the z layer from the init, it is always 0.

If I remove the above script, the problem does not happen.

I believe someone else had a similar problem some time ago, but I can’t find that thread. If anyone can help or find that thread, please let me know.

I think this is the post you’re referring to: Collection transitioning fade with sprite help

I don’t see anything obviously wrong with the code you posted.

I’d be curious to know if any solution was ever reached.

The only difference between the situation outlined in the thread above and my own is that the Z layer of my black fadeout object never changes. instead it is part of its own collection and always at the front.

I can take a look at the project if you like. bjorn.ritzl@king.com

1 Like

I would REALLY appreciate it. I should say I put a lot of swear words in my debugging.

Okay, I’ve added you as a collaborator. Open the branch called britzl.

Start the game, click “play”, click on the little cross so it says play, then click it again, and the level will load. That’s when the problem starts. (sometimes, the level sometimes doesn’t load. If that happens, the last thing the console prints will be a 1, and you should quit and open it again).

The relevant collections are “loader” and “1”.

What if you try printing the z value in the update, does it ever pass 0 then? Since you use go.EASING_OUTBACK, please note that it does animate past the target value, and then back (See the curve in the documentation). For instance, does the problem go away if you use go.EASING_LINEAR?

The animation you can see only affects the Y co-ordinate. The Z layer is not manipulated at any time, neither for the black fade out sprite nor the other sprite.

I am pretty sure this is a bug because the object that is causing the trouble has two sprites, and only the sprite mentioned in the code above causes the problem.

1 Like

@britzl if you haven’t started looking at this yet I’ve made a few changes that make the problem very clear. Make a new branch and investigate.

I’ll take a look now!

The z-value on sprite and sprite1 in tile.go are 2 and 0 respectively. This means that they will end up above sprite in scenechangerfadeout which has a z-value of 1 while fading.

Hey, what’s the best way to upload an example and make it public (as you often do?)

No worries, glad to help!

You could upload the source to Github. If you want to host a demo too you could use Github’s Pages feature to publish the HTML version to the same repo/site.

Yes, this is what I do. GitHub Pages is very easy to get started with, and it doesn’t have to mean that you must have your source code public as well. You can use GitHub Pages for individual GitHub repositories but you can also use GitHub Pages for your GitHub user (this is what @Mathias_Westerdahl is using for his Defold examples here https://jcash.github.io/).