Hey guys,
I started today working with scene transitions, I have a button in my “gameplay” scene, that when pressed, it takes you to the “main menu” scene.
Problem is, I get some errors on the spawned visual objects that try to destroy themselves when transition is complete .
I spawn the objects (in my “gameplay” scene) using a timer like so:
[lua]
timer.performWithDelay (500, function () – make sparkle particles
if (powerUpBoosterCount>0) then
local tmpShine = display.newImageRect(“images/ShineParticle.png”, 32, 16)
groupHUD:insert(tmpShine)
tmpShine.x = 80
tmpShine.y = 200
transition.to (tmpShine, {time=2000, alpha=0,
onComplete = function(target) target:removeSelf(); end} )
end
end , 0)
[/lua]
Now when I press the button it takes me to the main menu scene with this command:
[lua] storyboard.gotoScene(“initScene” , {time=400 , effect = “fromLeft”}) [/lua]
And I want to remove the gameplay scene entirely so I have this set up (in the “gameplay” scene):
[lua]
function scene:didExitScene(e)
storyboard.removeScene(“gameplay”)
end
scene:addEventListener(“didExitScene” , scene)
[/lua]
Problem is im getting an error :
“gameplay.lua:1034: attempt to call method ‘removeSelf’ (a nil value)”
Meaning the sparkle object that was spawned is trying to remove itself, but I guess there is nothing to remove… Any ideas how to handle this?
Roy.