Ok, I use this director thing to change levels (scenes).
I have different problems with it.
- I made a level and I copied it, so I have two levels. The first time everything works fine. Then I go to level2 (which is actually the same level in a separate lua file).
From the second level I come to the first level again and so on in an endless loop.
The more I change the levels, the more the level acts crazy.
My moving objects suddenly jump around on the y axis and move between different y coordinates, than I gave them.
- If I use a loading screen between levels, then if I go to level2 after the loading screen my background doesn’t load. To be honest nothing loads, except the animations, which are not inserted into the localGroup. On the screen I see only the loading screen and 4 animated images.
So I think, I should have unloaded everything by changing the scene, but appearantly it doesn’t happen.
Can somebody explain, how Corona/LUA handle this? How do I have to organize my levels?
I can’t find anything on it in a comprehensive way.
I don’t really understand these groups and tables and so…
Please can somebody explain it? [import]uid: 6587 topic_id: 5752 reply_id: 305752[/import]
Have you unloaded the Object in the old scene before you create it again in the new scene?
object:removeSelf()
[import]uid: 9577 topic_id: 5752 reply_id: 19715[/import]
No.
I have 5 such “enemies”:
[code]ghost1 = display.newImage (“images/ghost.png” ,102, 64);
ghost1.y = 64
localGroup:insert(ghost1)
function goUp1 ()
transition.to( ghost1, { time=1500, y=(ghost1.y - 128), onComplete=goDown1 } )
end
function goDown1 ()
transition.to( ghost1, { time=1500, y=(ghost1.y + 128), onComplete=goUp1 } )
end
goDown1()[/code]
They patrol between two points.
They go crazy with time.
Do I have to unload them?
I thought Director unloads everything by making a newGroup on every scene.
How do I unload them?
I assume that I have to put them into an event to be able to use the removeSelf function.
I downloaded the Ghosts vs Monsters game and there I don’t see objects removed by removeSelf.
The whole thing is very confusing for me…
[import]uid: 6587 topic_id: 5752 reply_id: 19717[/import]
Have you made them local?
for example
local ghost1 = display.newImage ("images/ghost.png" ,102, 64);
They have to be local otherwise they can’t be removed by director [import]uid: 10657 topic_id: 5752 reply_id: 19723[/import]
Oh, frack!
Nope…
Thanks!
I will make them local and see, what happens. [import]uid: 6587 topic_id: 5752 reply_id: 19746[/import]
No, making them local does nothing.
They behave the same strange way after the second scene change.
I think, I give up.
This whole thing is totally illogical… [import]uid: 6587 topic_id: 5752 reply_id: 19755[/import]