What is the best way to reload/restart the current scene with composer and keep information?

I am very new with the lua language and I am wondering if anyone can help me with a problem. I am trying to create a game where if the character is hit by an enemy, the level will reset, but this time she will have one less life. How can I make this occur?

  1. I will need to reset the scene.

  2. I will need to subtract a life as soon as the scene finishes reloading and keep the current score displaying at all times.

I have tried creating another scene that shows a button. If it is clicked, it takes you back to the scene, pretty much, reloading it. However, as soon as I try to jump, I get an error saying: Attempt to index getLinearVelocity() a nil value. I have checked my syntax and it is correct. I tried :applyForce() and it resulted in the same error. Removing this line causes everything to work fine, but my player loses the ability to jump.

This is the code I used for the scene with the button to return to level1.

local function tryAgain()

    composer.gotoScene(“level1”, “fade”, 500)

end

– create()

function scene:create( event )

    local sceneGroup = self.view

    

    local background = display.newImageRect(“black.png”, 1425, 950)

    background.x = _CX; background.y = _CY;

    local button = widget.newButton

    {

        width = 300,

        height = 200,

        label = “Try Again”,

        onEvent = tryAgain

    }

    

    button.x = _CX

    button.y = _CY

    sceneGroup:insert(background)

    sceneGroup:insert(button)

end

– show()

function scene:show( event )

    local sceneGroup = self.view

    local phase = event.phase

    if ( phase == “will” ) then

        – Code here runs when the scene is still off screen (but is about to come on screen)

    elseif ( phase == “did” ) then

        local prevScene = composer.getSceneName(“previous”)

        if(prevScene) then

            composer.removeScene(prevScene)

        end

        

    end

end

A solution would be greatly appreciated.

Sincerely,

Alex

For your first way

this is most likely physics or timer or event is still running when you go to another scene. You are suppose to remove or pause this when you got to another scene. 

For your 2nd question: i need some code to work with. This is just the reset scene. I need at least an idea on how your code is setup.

  1. you should move all your objects back (need code to help further)

  2. before you goto another scene you can do :

    local lifeCount = composer.getVariable( “lifeCount” ) if lifeCount == nil then lifeCount = 5 end composer.setVariable( lifeCount, lifeCount-1 )

Their are other way will modules or passing  between scenes, but this works

Dear Scott,

Thank you very much for your reply, I am extremely appreciative of your help. I am 12 years old and this can get frustrating at times for me. 

Here are the most important sections of my code:

local function sendEnemies()

        timeCounter = timeCounter + 1

        if((timeCounter%enemySendSpeed) == 0) then

            enemyCounter = enemyCounter + 1

            enemySendSpeed = enemySendSpeed - enemyIncrementSpeed

            if(enemySendSpeed <= enemyMaxSendSpeed) then

                enemySendSpeed = enemyMaxSendSpeed

            end

            local temp = math.random(1,3)

            if(temp == 1) then

                enemy[enemyCounter] = display.newSprite(beetle, beetleSequenceData)

            elseif (temp == 2) then

                enemy[enemyCounter] = display.newSprite(scorpion, scorpionSequenceData)

            else

                enemy[enemyCounter] = display.newSprite(vulture, vultureSequenceData)

            end

            

            enemy[enemyCounter].x = _R + 150

            enemy[enemyCounter].y = _CY - (_CH * 0.1)

            enemy[enemyCounter].xScale = -1

            enemy[enemyCounter].id = “enemy”

            enemy[enemyCounter].isFixedRotation = true

            

            transition.to(enemy[enemyCounter], {x=_L - 50, time=enemyTravelSpeed, onComplete= function(self)     

                if (self~= nil) then display.remove(self); end

            end})

            if(temp == 1) then

                physics.addBody(enemy[enemyCounter], “dynamic”, physicsData:get(“beetle”))

            elseif(temp == 2) then

                physics.addBody(enemy[enemyCounter], “dynamic”, physicsData:get(“scorpion”))

            elseif(temp == 3) then

                physics.addBody(enemy[enemyCounter], “dynamic”, physicsData:get(“vulture”))

                enemy[enemyCounter].gravityScale = 0

            end

            

            enemy[enemyCounter]:setSequence(“moving”)

            enemy[enemyCounter]:play()

        end

    end

for i=1, livesCount do

        lives[i] = display.newImageRect(“heart.png”, 50, 50)

        lives[i].x = _L + (i * 65) - 25

        lives[i].y = _T + 50

    end

    

    function scrollMountains(self,event)

        if self.x < -self.width * 0.6 then

            self.x = self.width * 1.32

        else

            self.x = self.x - self.value

        end

    end

    

    horizon.enterFrame = scrollMountains

    Runtime:addEventListener(“enterFrame”, horizon)

    

    horizon2.enterFrame = scrollMountains

    Runtime:addEventListener(“enterFrame”, horizon2)

    

    mountainback.enterFrame = scrollMountains

    Runtime:addEventListener(“enterFrame”, mountainback)

    

    mountainback2.enterFrame = scrollMountains

    Runtime:addEventListener(“enterFrame”, mountainback2)

    

    mountain.enterFrame = scrollMountains

    Runtime:addEventListener(“enterFrame”, mountain)

    

    mountain2.enterFrame = scrollMountains

    Runtime:addEventListener(“enterFrame”, mountain2)

    

    trees.enterFrame = scrollMountains

    Runtime:addEventListener(“enterFrame”, trees)

    

    trees2.enterFrame = scrollMountains

    Runtime:addEventListener(“enterFrame”, trees2)

    

    local characterOptions = 

    {

        width = 100,

        height = 126.5,

        numFrames = 10,

        sheetContentWidth = 500,

        sheetContentHeight = 253

    }

    

    local sheet_character = graphics.newImageSheet(“girl-running.png”, characterOptions)

    

    local sequence_character = {

        {name = “run”, start = 1, count = 10, time = 800, loopCount = 0, loopDirection = “forward”}

    }

    

    local character = display.newSprite(sheet_character, sequence_character)

    

    character.x = _L + 250

    character.y = _CY - (character.height * 0.3)

    character:play()

    character.id = “character”

    physics.addBody(character, “dynamic”, {bounce = 0})

    character.isFixedRotation = true

    

    function touchScreen(event)

        if (event.phase == “began”) then

            if (canJump == true) then

                character:applyForce(0, -60, self.x, self.y)

            end

            canJump = false

        end

        return true

    end

local function showPlayerHit()

            character.alpha = 0.5

            local tmr_onPlayerHit = timer.performWithDelay(1, playerHit, 1)

        end

        

            if(event.object1.id == “enemy” and event.object2.id == “character”) then

                showPlayerHit()

                removeOnPlayerHit(event.object1, nil)

            end

        

            if(event.object1.id == “character” and event.object2.id == “enemy”) then

                showPlayerHit()

                removeOnPlayerHit(nil, event.object2)

            end

        

            if(event.object1.id == “enemy” and event.object2.id == “enemy”) then

                event.contact.isEnabled = false    

            end

        

            if(event.object1.id == “character” and event.object2.id == “ground”) then

                canJump = true

            end

        

            if(event.object1.id == “ground” and event.object2.id == “character”) then

                canJump = true

            end

    end

    

    Runtime:addEventListener(“enterFrame”, sendEnemies)

    Runtime:addEventListener(“touch”, touchScreen)

    Runtime:addEventListener(“collision”, onCollision)

I apologize if it is a lot of code.

Thank you very much for your help.

Sincerely,

Alex

So a reset function would something like

local function resetLevel () character.x = \_L + 250 character.y = \_CY - (character.height \* 0.3) for i = 1, #enemy do display.remove(enemy[i]) enemy[i] = nil end end

i don’t see a go to reset scene but try composer.showOverlay

also i would add the scene events and on the hide (event.phase == “will”) do

physics.pause()

Runtime:removeEventListener(“enterFrame”, sendEnemies)

look at the composer docs and try to composerfy( made a new word :slight_smile: ) your code

Like add scene groups to you level or some kind of scene management. If you do use composer you can use things like showOverlay.

Thank you very much for your quick reply, I am working to implement it into my code. I just have one question: how would cause the resetLevel function to trigger and where would I put the composer.showOverlay? 

Sorry for the late reply.

Sincerely,

Alex

In first code you showed what looked like to be a gamover scene. when ever you want call a reset and go to let’s call it gameover.lua you should call resetLevel() and then composer.showOverlay(“gameover”). Of course when your done you would use hide overlay.

My playerHit() function will cause the level to restart, so overall:

  1. Call resetLevel function in playerHit

  2. Use performWithDelay to call composer.showOverlay (or just add it normally into the playerHit() function)

  3. Declare lifeCount in playerHit()

Also, where would I add hideOverlay, for now I am just hoping to restart one scene instead of going to another, then going back.

The easy way:

 

main.lua (not a real scene but starts the whole process) --> menu.lua  -->  level1.lua  --> tryagain.lua --> level1.lua

 

Now in tryagain.lua display a message for a few seconds and then while that’s displaying call storyboard.removeScene(“level1”); storyboard.gotoScene(“level1”)

 

Rob Miracle had posted this on a conversation related to mine, could the same thing work with composer? 

 

Thank you.

Yes composer can do this, I was just making a suggestion that if you remove the scene from code and go back it takes a lot of “processing power” to do this and could talk longer that is why thought show overlay would work. But will all that out the way you can is use composer.gotoScene and composer.removeScene just like storyboard. Note removeScene removes the scene from memory and could take longer load but it is up to you

Thanks, but could I still keep data? For example:

level1.lua: Current Score is 900, Lives is Lives - 1

Can I keep the current score at 900, and the correct number of lives after the game restarts and how?

Thank you.

Thier are lots of ways to do this
Get and set variables with https://docs.coronalabs.com/api/library/composer/setVariable.html
https://docs.coronalabs.com/api/library/composer/getVariable.html

Toss data back and forth with composer.gotoScene(“tryagain”,{params= {variable1 = 100, anotherVar= “hello”}})

Then on next scene in the event like create:scene(event)
print(event.params.anotherVar)

You can use modules
https://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/

I tried using this function: 

function tryAgain() 

        composer.removeScene(“level1”)

        composer.gotoScene(“level1”, “fade”, 500)

    end

In my tryagain.lua, when I reach and try to go back to level1, I get this error: Attempt to perform arithmetic on field ‘width’ a nil value, that points to line 119 in my level1.lua.

function scrollMountains(self,event)

        if self.x < -self.width * 0.6 then --Line 119

            self.x = self.width * 1.32 

        else

            self.x = self.x - self.value

        end

end

The scrollMountains function is inside the scene:create function and makes my background scroll, do I have to move it elsewhere?

Sincerely,

Alex

If you are trying to wipe the scene with removeScene, you are deleting all on objects in sceneGroup. Composer does not auto remove runtime event listeners. You have to remove them your self. So it is still going even when you go tryagain.

Where would I remove the event Listeners?

Would I have to remove all existing eventListeners manually?

All runtime event need to be removed via Runtime:removeEventListener(“the event here”, theFunctionHere)

Ideally you would put this in scene:destroy but you may want to also put in scene:hide and I would put all Runtime:addEventListener in scene:show did phase. You may have forward declare like so
local iAmAFunction

local function iAmFuntion2()
iAmAFunction= function()
print(“we called I am a function”)
end
end

iAmFuntion2()
iAmAFunction()

Scene template here
https://docs.coronalabs.com/api/library/composer/index.html#template

So, remove allEventListeners in the scene:hide and in the scene:destroy, and forward declare all functions?

I apologize that I have so many questions.

Thank you.

You might have to foward declare depending on how your code looks, but I would try to but you level1 lua inside the composer template which I linked to above in my previous post. Thier is no magic api that removes all event listeners(that I am aware unless you code one yourself but never mind) you have to remove them manually in scene: destroy and hide. If you don’t remove them you could have a memory leak or bad performance. Because you are calling add event listeners to Runtime every time you call composer.gotoscene(“level1”) and basically adding a pound to app event time you use event listeners if you don’t remove the weight properly the app will start to slow down.

I have tried everything and it still does not work, I keep getting all kinds of errors. Here is my level1.lua and my level1-Try-Again.lua, 

 ----------------------------------------------------------------------------------------- -- -- level1.lua -- ----------------------------------------------------------------------------------------- local composer = require( "composer" ) local scene = composer.newScene() -- include Corona's "physics" library local physics = require "physics" physics.start() physics.setGravity(0, 18) -------------------------------------------- -- forward declarations and other locals local screenW, screenH, halfW = display.actualContentWidth, display.actualContentHeight, display.contentCenterX local vx, vy local lives = {} -- table that will hold the lives object local livesCount = 4 -- the number of lives the player has local canJump = false local horizon local horizon2 local mountainback local mountainback2 local mountain local mountain2 local trees local trees2 local ground local beetleSheetData = {width=166.67, height=106, numFrames=10, sheetContentWidth=500, sheetContentHeight=424} local scorpionSheetData = {width=169, height=108, numFrames=10, sheetContentWidth=1690, sheetContentHeight=108} local vultureSheetData = {width=121, height=117.25, numFrames=4, sheetContentWidth=121, sheetContentHeight=469} local beetle = graphics.newImageSheet("beetle-walking2.png", beetleSheetData) local scorpion = graphics.newImageSheet("scorpion-walking.png", scorpionSheetData) local vulture = graphics.newImageSheet("vulture-flying.png", vultureSheetData) local scorpionSequenceData = { {name="moving", start=1, count=10, time=1000, loopCount=0} } local beetleSequenceData = { {name="moving", start=1, count=10, time=1000, loopCount=0} } local vultureSequenceData = { {name="flapping", start=1, count=4, time=500, loopCount=0} } local enemy = {} local timeCounter = 0 -- how much time has passed in the game local enemyCounter = 0 -- number of enemies sent local enemySendSpeed = 90 -- how often to send the enemies local enemyTravelSpeed = 7000 -- how fast enemies travel across the screen local enemyIncrementSpeed = 1 -- how much to increase the enemy speed local enemyMaxSendSpeed = 55 -- max send speed, if this is not set, the enemies could just be one big flood local physicsData = (require "enemies").physicsData(1.0) function scene:create( event ) -- Called when the scene's view does not exist. -- -- INSERT code here to initialize the scene -- e.g. add display objects to 'sceneGroup', add touch listeners, etc. local sceneGroup = self.view horizon = display.newImageRect("Sprite Sheets and Projects/Mountains/PALALLAX/horizon(5).png", 1425, 950) horizon.x = \_CX horizon.y = \_CY horizon.value = 0.2 horizon2 = display.newImageRect("Sprite Sheets and Projects/Mountains/PALALLAX/horizon(5).png", 1425, 950) horizon2.x = horizon.width \* 1.4 horizon2.y = \_CY horizon2.value = 0.2 mountainback = display.newImageRect("Sprite Sheets and Projects/Mountains/PALALLAX/mountainback(4).png", 1425, 950) mountainback.x = \_CX mountainback.y = \_CY mountainback.value = 0.4 mountainback2 = display.newImageRect("Sprite Sheets and Projects/Mountains/PALALLAX/mountainback(4).png", 1425, 950) mountainback2.x = mountainback.width \* 1.4 mountainback2.y = \_CY mountainback2.value = 0.4 mountain = display.newImageRect("Sprite Sheets and Projects/Mountains/PALALLAX/mountain(3).png", 1425, 950) mountain.x = \_CX mountain.y = \_CY mountain.value = 1 mountain2 = display.newImageRect("Sprite Sheets and Projects/Mountains/PALALLAX/mountain(3).png", 1425, 950) mountain2.x = mountain.width \* 1.4 mountain2.y = \_CY mountain2.value = 1 trees = display.newImageRect("Sprite Sheets and Projects/Mountains/PALALLAX/trees(2).png", 1425, 950) trees.x = trees.width \* 1.4 trees.y = \_CY trees.value = 5 trees2 = display.newImageRect("Sprite Sheets and Projects/Mountains/PALALLAX/trees(2).png", 1425, 950) trees2.x = trees.width \* 1.4 trees2.y = \_CY trees2.value = 5 ground = display.newImageRect("Sprite Sheets and Projects/Mountains/PALALLAX/ground(1).png", 1425, 950) ground.x = \_CX ground.y = \_CY ground.id = "ground" local groundShape = { -halfW \* 1.4, ground.height \* 0.32, halfW \* 1.4, ground.height \* 0.32, halfW \* 1.4, ground.height \* 0.52, -halfW \* 1.4, ground.height \* 0.52} physics.addBody( ground, "static", { friction=1, bounce = 0, shape=groundShape }) for i=1, livesCount do lives[i] = display.newImageRect("heart.png", 50, 50) lives[i].x = \_L + (i \* 65) - 25 lives[i].y = \_T + 50 end function scrollMountains(self,event) if self.x \< -self.width \* 0.6 then self.x = self.width \* 1.32 else self.x = self.x - self.value end end horizon.enterFrame = scrollMountains Runtime:addEventListener("enterFrame", horizon) horizon2.enterFrame = scrollMountains Runtime:addEventListener("enterFrame", horizon2) mountainback.enterFrame = scrollMountains Runtime:addEventListener("enterFrame", mountainback) mountainback2.enterFrame = scrollMountains Runtime:addEventListener("enterFrame", mountainback2) mountain.enterFrame = scrollMountains Runtime:addEventListener("enterFrame", mountain) mountain2.enterFrame = scrollMountains Runtime:addEventListener("enterFrame", mountain2) trees.enterFrame = scrollMountains Runtime:addEventListener("enterFrame", trees) trees2.enterFrame = scrollMountains Runtime:addEventListener("enterFrame", trees2) local characterOptions = { width = 100, height = 126.5, numFrames = 10, sheetContentWidth = 500, sheetContentHeight = 253 } local sheet\_character = graphics.newImageSheet("girl-running.png", characterOptions) local sequence\_character = { {name = "run", start = 1, count = 10, time = 800, loopCount = 0, loopDirection = "forward"} } local character = display.newSprite(sheet\_character, sequence\_character) character.x = \_L + 250 character.y = \_CY - (character.height \* 0.3) character:play() character.id = "character" physics.addBody(character, "dynamic", {bounce = 0}) character.isFixedRotation = true function touchScreen(event) if (event.phase == "began") then if (canJump == true) then character:applyForce(0, -45, self.x, self.y) end canJump = false end return true end local function sendEnemies() timeCounter = timeCounter + 1 if((timeCounter%enemySendSpeed) == 0) then enemyCounter = enemyCounter + 1 enemySendSpeed = enemySendSpeed - enemyIncrementSpeed if(enemySendSpeed \<= enemyMaxSendSpeed) then enemySendSpeed = enemyMaxSendSpeed end local temp = math.random(1,3) if(temp == 1) then enemy[enemyCounter] = display.newSprite(beetle, beetleSequenceData) elseif (temp == 2) then enemy[enemyCounter] = display.newSprite(scorpion, scorpionSequenceData) else enemy[enemyCounter] = display.newSprite(vulture, vultureSequenceData) end enemy[enemyCounter].x = \_R + 150 enemy[enemyCounter].y = \_CY - (\_CH \* 0.1) enemy[enemyCounter].xScale = -1 enemy[enemyCounter].id = "enemy" enemy[enemyCounter].isFixedRotation = true transition.to(enemy[enemyCounter], {x=\_L - 50, time=enemyTravelSpeed, onComplete= function(self) if (self~= nil) then display.remove(self); end end}) if(temp == 1) then physics.addBody(enemy[enemyCounter], "dynamic", physicsData:get("beetle")) elseif(temp == 2) then physics.addBody(enemy[enemyCounter], "dynamic", physicsData:get("scorpion")) elseif(temp == 3) then physics.addBody(enemy[enemyCounter], "dynamic", physicsData:get("vulture")) enemy[enemyCounter].gravityScale = 0 end enemy[enemyCounter]:setSequence("moving") enemy[enemyCounter]:play() end end function onGameOver() Runtime:removeEventListener("touch", touchScreen) Runtime:removeEventListener("enterFrame", sendEnemies) Runtime:removeEventListener("collision", onCollision) transition.pause() for i=1,#enemy do if(enemy[i] ~= nil) then display.remove(enemy[i]) enemy[i] = nil end end composer.gotoScene("level1-Try-Again", "fade", 500) end local function resetLevel() character.x = \_L + 250 character.y = \_CY - (character.height \* 0.3) for i = 1, #enemy do display.remove(enemy[i]) enemy[i] = nil end end physics.setDrawMode("hybrid") local function playerHit() character.x = \_L + 250 character.alpha = 1 lives[livesCount].alpha = 0 livesCount = livesCount - 1 if(livesCount \< 1) then onGameOver() end end local function onCollision(event) local function removeOnPlayerHit(obj1, obj2) if(obj1 ~= nil and obj1.id == "enemy") then display.remove(obj1) end if(obj2 ~= nil and obj2.id == "enemy") then display.remove(obj2) end end local function showPlayerHit() character.alpha = 0.5 local tmr\_onPlayerHit = timer.performWithDelay(1, playerHit, 1) end if(event.object1.id == "enemy" and event.object2.id == "character") then showPlayerHit() removeOnPlayerHit(event.object1, nil) end if(event.object1.id == "character" and event.object2.id == "enemy") then showPlayerHit() removeOnPlayerHit(nil, event.object2) end if(event.object1.id == "enemy" and event.object2.id == "enemy") then event.contact.isEnabled = false end if(event.object1.id == "character" and event.object2.id == "ground") then canJump = true end if(event.object1.id == "ground" and event.object2.id == "character") then canJump = true end end Runtime:addEventListener("enterFrame", sendEnemies) Runtime:addEventListener("touch", touchScreen) Runtime:addEventListener("collision", onCollision) sceneGroup:insert(horizon) sceneGroup:insert(horizon2) sceneGroup:insert(mountainback) sceneGroup:insert(mountainback2) sceneGroup:insert(mountain) sceneGroup:insert(mountain2) sceneGroup:insert(trees) sceneGroup:insert(trees2) sceneGroup:insert(ground) sceneGroup:insert(character) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then -- Called when the scene is still off screen and is about to move on screen elseif phase == "did" then -- Called when the scene is now on screen -- -- INSERT code here to make the scene come alive -- e.g. start timers, begin animation, play audio, etc. physics.start() end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then -- Called when the scene is on screen and is about to move off screen -- -- INSERT code here to pause the scene physics.pause() Runtime:removeEventListener("enterFrame", sendEnemies) elseif phase == "did" then end end function scene:destroy( event ) -- Called prior to the removal of scene's "view" (sceneGroup) -- -- INSERT code here to cleanup the scene -- e.g. remove display objects, remove touch listeners, save state, etc. local sceneGroup = self.view end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) ----------------------------------------------------------------------------------------- return scene----------------------------------------------------------------------------------------- level1-Try-Again.lua(Not actually in the document): local composer = require( "composer" ) local scene = composer.newScene() local widget = require "widget" widget.setTheme("widget\_theme\_ios7") -- ----------------------------------------------------------------------------------- -- Code outside of the scene event functions below will only be executed ONCE unless -- the scene is removed entirely (not recycled) via "composer.removeScene()" -- ----------------------------------------------------------------------------------- local tryAgain -- ----------------------------------------------------------------------------------- -- Scene event functions -- ----------------------------------------------------------------------------------- -- create() function scene:create( event ) local sceneGroup = self.view function tryAgain() composer.removeScene("level1") composer.gotoScene("level1", "fade", 500) end -- Code here runs when the scene is first created but has not yet appeared on screen local background = display.newImageRect("black.png", 1500, 938) background.x = \_CX background.y = \_CY tryAgain = widget.newButton( { id = "tryAgain", label = "Try again", onEvent = tryAgain } ) tryAgain.x = \_CX tryAgain.y = \_CY sceneGroup:insert(background) sceneGroup:insert(tryAgain) end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is on screen (but is about to go off screen) elseif ( phase == "did" ) then -- Code here runs immediately after the scene goes entirely off screen end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene&nbsp;

What do I have to do in both documents to ensure that this will work? The composer is something very new to me, and I have been stuck on this problem for quite sometime. Can you look through my code and make any changes that are necessary, thank you very much. 

Sincerely,

Alex

What error are you getting