Hi,
I’m writing an app which uses the Director class by Ricardo Rauber.
It’s working great with one exception.
When I switch to a screen which has a rotating image I get errors when I leave that screen.
When the director makes the switch to “mainscreen” the background image remains in place.
Eventually the emulator throws this error
file.lua:31: attempt to perform arithmetic on field ‘rotation’ (a nil value)
stack traceback:
I’ve tried a bunch of things with no luck. Here’s the current code.
[lua]-- Main menu
module(…, package.seeall)
– Main function - MUST return a display.newGroup()
function new()
local localGroup = display.newGroup()
local spinBg = display.newImage( “correctBg1.png”, true )
local face = display.newImage( “smileyFace.png”, true )
change = function ()
–spinBg:removeSelf()
–face:removeSelf()
Runtime:removeEventListener( “enterFrame”, animate )
director:changeScene( “mainscreen”);
end
localGroup:insert(spinBg)
spinBg.x = display.contentWidth / 2
spinBg.y = display.contentHeight / 2
face.x = display.contentWidth / 2
face.y = display.contentHeight / 2
localGroup:insert(face)
local function animate( event )
spinBg.rotation = spinBg.rotation + 1
end
Runtime:addEventListener( “enterFrame”, animate );
timer.performWithDelay( 5000, change );
return localGroup
end[/lua]
Any suggestions?
[import]uid: 24363 topic_id: 11612 reply_id: 311612[/import]