I am using a cut down version of director class; the one by Lerg in the code exchange.
It works fine but I am having issues and nightmares trying to cancel the timers and runtimes, I have a few basic questions that you may be able to help me with.
My game will end when timer reaches “0” or lives =“0”, I am trying to run a gameOver function at that point which will kill all timers and event listeners.
The lives = “0” function is in scene_bee and the timer =“0” function is in scene_game(main).
I did have this for lives =“0”
--bee.lua
if lives \> 0 then
lifeBar[lives].isVisible = false
lives = lives -1
lifeBar[lives].isVisible = true
if lives \<= 0 then
director:changeScene('scene\_gameover')
this is functioning correctly the only issue is that timers,runtimes and transitions where still running so the scene still played in the background less the objects I had added to localGroup.
In my scene_game(main) I added a function that contained all runtime, and timers ready for removal using timer.cancel() and nil, and removeEventListener.
I included the director:changeScene('scene\_gameover')
at the end to be called last.
I then added a function calling the gameOver function.
This didnt work whatsoever even though I tried many different things, infact I had a sleepless night thinking about it (I am sure we all do).
The objects left on screen are a 2 objects that are sprites and those damn pesky leaves transitioning across the screen still.
- So, if I list all my timers/eventListeners in a function called gameOver, can I cancel them from a call to that function from my
"lifes="0" then ( what do I do?) --function gameOver()--
function.
2)How are sprite sheets dealt with? I cant add them to LocalGroup
I would like to say I am not asking you guys without trying lots of stuff first. A little guidance would be much appreciated.
[import]uid: 127675 topic_id: 31102 reply_id: 331102[/import]