Hi,
I can’t really get my head around this one. I’m using a timer.performWithDelay to spawn multiple sprite animations that rain down over the screen. If I let the whole timer run until it’s finished all is well. But if I go to another scene (storyboard) while the timer is still running I get an error in the new scene - “Attempt to call method ‘removeSelf’ (a nil value)”.
So the timer is somehow still running - or at least spawnConfetti() still is and is trying to remove an object from the display group that is no longer there because of the scene change.
I’ve tried to cancel the timer but it has no effect.
Any ideas?
Best
Fredrik
local function spawnConfetti() local confettiSpawn = display.newSprite( mySheet, sequenceData ) confettiSpawn.x = math.random(-100, 1200); confettiSpawn.y = -40; confettiSpawn:play() group:insert( confettiSpawn ) transition.to( confettiSpawn, { time = math.random(3000, 6000), x = math.random(-100, 1200) , y = screenH + 50, alpha = 0, onComplete = function(obj) if obj then obj:removeSelf() obj = nil end end } ); end local countSprites = 100 local tmr = timer.performWithDelay(100, spawnConfetti, countSprites)