Hi Everyone,
Sorry if this is a silly and obvious question to ask but I have been trying to fix it for over an hour now with no luck.
Anyways my problem is that I am using the director class to switch scenes but every time I do it brings all the images and objects from the previous scene into the new scene except for the button I am pressing! So I was wondering what it is I am doing wrong and how I can fix it.
Here is the code for the my first scene with a button:
module(..., package.seeall)
local localGroup = display.newGroup()
local function newGameBeganFunction()
end
local function newGameReleasedFunction()
director:changeScene("screen2","crossfade")
end
local function initVars ()
local bg = display.newImage ("appBgBlank.png",0, 300)
local dirt = display.newImage ("floor.png",0,430)
newGameBTN = movieclip.newAnim({"re-we.png", "re-we.png"})
newGameBTN.x = display.contentWidth / 2
newGameBTN.y = 5
newGameBTN.sound = clickSND
newGameBTN.beganFunction = newGameBeganFunction
newGameBTN.releasedFunction = newGameReleasedFunction
newGameBTN.removeListenerOnTouch = true
localGroup:insert(newGameBTN)
newGameBTN:addEventListener("touch", uiButton.handleEvent)
end
function clean ( event )
print("cleaned")
end
function new()
initVars()
return localGroup
end
And here is the code for the scene I am going to:
module(..., package.seeall)
local localGroup = display.newGroup()
local function initVars ()
local dirt = display.newImage ("floor.png",0,430)
physics.addBody (dirt, "static",{bounce=0.3})
local bg = display.newImage ("appBgBlank.png")
local hero = display.newImage ("re-we.png")
hero.x = display.stageWidth/2
physics.addBody(hero, {density=3.0, friction=0.5, bounce=0.3 } )
end
function clean ( event )
print("cleaned")
end
function new()
initVars()
return localGroup
end
Thanks,
Kevin [import]uid: 2752 topic_id: 7224 reply_id: 307224[/import]