I created an animation with images transition with Corona SDK version 2018.3280, it works fine when the application starts, but when I open a new scene and return to the scene where the animation is, it goes crazy.
Please make a TINY demo app that demonstrates this issue so we can see all of what you’re doing. That code alone is not likely the whole issue.
Tip: When I read the title I thought this would be about sprites (animations).
For your info (to avoid future confusion), transition.* may be used to move, modify, etc objects, but it isn’t generally referred to as animation.
We simply call them transitions.
You can attach zip files to posts, by zipping up the project, then clicking the ‘more reply options’ button below. That will then pull up this interface:
Hi again. This is NOT a mini example. It looks like your full game/app… I don’t have the time or desire to dig through a full project to find the problem code.
Also, it is a good debug step to reproduce issues in a mini testbench. This is often how I find the source of my problem.
Can you just make an example that demonstrates the single issue you’re posting about?
OK. I’ve looked AT THE ORIGINAL POSTED CODE and I can see that you have some bad behavior, but I don’t know where it is coming from.
Things I noticed:
code needs some general cleaning and indenting. i’d suggest 3 spaces instead of 2. I’m mentioning this because it is hard to read and thus is hard to debug.
You seem to be destroying home when you leave. If you’re going to do this and if your transition time is 0, there is no reason to use the show() method.
You start timers TWICE in show. i.e. They are NOT in in a will or did phase check.
‘time’ is a global. it should be a file-level local declared at the top
Sorry, I could’t figure it out. This is why I ask for super simple tiny demos. There is just too much code to penetrate.
My best guess is that you’re staring the timer multiple times and not properly canceling them since you only have the handle to the last timer you started.
That Cool! Thanks a lot, although the code changed seems a little complicated (I am a beginner) I was happy that my problem was solved even with a little more code.
I’ll take a look at the modifications to see if I learn!
I made those changes because your original method had a number of best-practices issues that would have caused no end of problems:
globals all over the place (and quite possibly having the same names used in other scenes?)
destroying scenes on hide —> did phase (some say “Yes, it is OK.”, Is say “No, it is not.”)
ignoring will/did phases in show when setting up timers
…
Also, you were using timers and transitions in a sub-optimal way.
My unified single transition + onComplete listener approach is shorter and safer. That said, it is more technical, so I understand if it seems confusing at first.
Please make a TINY demo app that demonstrates this issue so we can see all of what you’re doing. That code alone is not likely the whole issue.
Tip: When I read the title I thought this would be about sprites (animations).
For your info (to avoid future confusion), transition.* may be used to move, modify, etc objects, but it isn’t generally referred to as animation.
We simply call them transitions.
You can attach zip files to posts, by zipping up the project, then clicking the ‘more reply options’ button below. That will then pull up this interface:
Hi again. This is NOT a mini example. It looks like your full game/app… I don’t have the time or desire to dig through a full project to find the problem code.
Also, it is a good debug step to reproduce issues in a mini testbench. This is often how I find the source of my problem.
Can you just make an example that demonstrates the single issue you’re posting about?