hi Corona fans,
i’m doing a game with cars popping out of the edge of the screen (not unlike ‘airport’ but with cars)
before popping out i’d like to give a warning to the player so i’ve put a timer for 1 second where the I set the car red.
when the timer finishes it goes back to its normal color and goes.
like this
mycar:setFillColor(255,0,0) -- make the carRED tmmyCarReadyToGo = timer.performWithDelay( 1000, function() myCarReadyToGo(mycar) end ) function myCarReadyToGo(obj) print ("myCarReadyToGo. OK now\>",obj.type) obj.intransit = true obj:setFillColor(1) --\<\<\<\<===== this is where it crash !! end -- myCarReadyToGo ----------------------------------------------------------------------
Now I have many cars hence many timers calling the same function. at different times
this works well enough but if I want to refresh the screen (calling a reset composer scene) while the timer is on , it crashes with
ERROR: Runtime error
21:24:03.694 scene1.lua:1371: attempt to call method ‘setFillColor’ (a nil value)
21:24:03.694 stack traceback:
21:24:03.694 scene1.lua:1371: in function ‘myCarReadyToGo’
21:24:03.694 scene1.lua:189: in function ‘_listener’
21:24:03.694 ?: in function ‘?’
21:24:03.694 ?: in function <?:190>
of course before calling the reset composer screen i try to cancel any running timers.
but i think that it where the problem lies, that it gets confused about what timer is on ?
am I supposed to create an array of timers for each of the car ? calling the same function ?
help !
ps: it doesnt crash everytime telling me it’s a timing issue. i could probably have the reset button wait longer that the timers themselves (e.g. 2sec) but that would be quite annoying for the player.