firstly you’re calling startscreen twice
[lua]local room = StartScreen
local scene = display.newImage( “StartScreen.png”, 0, 0, true ) – once here
local funtion sceneSelector()
if room == StartScreen then
scene = display.newImage( “StartScreen.png”, 0, 0, true ) – once here
…
end
sceneSelector()[/lua]
secondly, i’m guessing display.newImage does exactly that, creates a new image. you’re just changing your pointer from your first image to your second. I suggest you remove the image first
maybe:
[lua]local room = StartScreen
local scene
local funtion sceneSelector()
local newScene
if(scene~=nil) then scene:removeSelf() end – remove original if present
if room == StartScreen then
newScene = display.newImage( “StartScreen.png”, 0, 0, true )
…
else…
end
return newScene
end
scene = sceneSelector()[/lua]
personally i’d add a parameter… something like (although I haven’t thought it through exactly)
[lua]local room = StartScreen – current room
local scene
local funtion sceneSelector(newRoom)
local newScene
if(newRoom == room and scene~=nil) then return {scene, room) – (basically do nothing)
if(scene~=nil) then scene:removeSelf() end – remove original if present
if newRoom == StartScreen then
newScene = display.newImage( “StartScreen.png”, 0, 0, true )
…
else…
end
return {newScene, newRoom}
end
scene,room = sceneSelector(room) – create initial state
local newRoom = Whatever
scene,room = sceneSelector(newRoom) – test new scene[/lua] [import]uid: 6645 topic_id: 4294 reply_id: 13373[/import]