my current code is below
main.lua
display.setStatusBar( display.HiddenStatusBar )
local storyboard = require "storyboard"
-- background should appear behind all scenes
-- local background = display.newImage( "assets/graphics/bg.png" )
-- tab bar image should appear above all scenes
local tabBar = display.newImage( "assets/graphics/tabbar.png" )
tabBar:setReferencePoint( display.BottomLeftReferencePoint )
tabBar.x, tabBar.y = 0, display.contentHeight
-- put everything in the right order
local display\_stage = display.getCurrentStage()
-- display\_stage:insert( background )
display\_stage:insert( storyboard.stage )
display\_stage:insert( tabBar )
-- go to the first scene
storyboard.gotoScene( "scene1", "fade", 300 )
and
scene1.lua
[code]
– Room 1
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local lastScene = storyboard.getPrevious()
– BEGINNING OF YOUR IMPLEMENTATION
local background, room2, blackKey, blackdoorlocked, text1
– Touch event listener for background image
local function gotoRoom2( self, event )
if event.phase == “began” then
storyboard.gotoScene( “scene2”, “fade”, 400 )
return true
end
end
local function doorlocked( self, event )
if event.phase == “began” then
– storyboard.gotoScene( “scene20”, “fade”, 400 )
text1 = display.newText( “Door is Locked, the key should be near by”, 0, 245, native.systemFontBold, 20 )
text1:setTextColor( 255 )
transition.to(text1, {time=1000, onComplete = function() display.remove(text1) end})
return true
elseif(event.phase == “moved”) then
– Do Something During the “moved” phase
transition.to(self, {x = event.x, y = event.y, time=0});
end
end
local function onSceneTouchx( self, event )
if event.phase == “began” then
storyboard.gotoScene( “scene3”, “fade”, 400 )
return true
end
end
– Called when the scene’s view does not exist:
function scene:createScene( event )
local screenGroup = self.view
background = display.newImage( “assets/graphics/Room1.png”, 0, 0 )
screenGroup:insert( background )
blackdoorlocked = display.newImage( “assets/graphics/BlackLock2.png”, 175, 0 )
screenGroup:insert( blackdoorlocked )
blackdoorlocked.touch = doorlocked
room2 = display.newImage( “assets/graphics/gotoRoom2.png”, 175, 0 )
screenGroup:insert( room2 )
room2.touch = gotoRoom2
blackKey = display.newImage( “assets/graphics/BlackKey.png”, 100, 200 )
screenGroup:insert( blackKey )
blackKey.touch = onSceneTouchx
print( “\n1: createScene event”)
end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
print( “1: enterScene event” )
– remove previous scene’s view
storyboard.purgeScene( lastScene )
print( “last scene was:”, lastScene ) – output: last scene name
– Update Lua memory text display
blackKey:addEventListener( “touch”, blackKey )
room2:addEventListener( “touch”, room2 )
blackdoorlocked:addEventListener( “touch”, blackdoorlocked )
end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
print( “1: exitScene event” )
– remove touch listener for image
blackKey:removeEventListener( “touch”, blackKey )
room2:removeEventListener( “touch”, room2 )
blackdoorlocked:removeEventListener( “touch”, blackdoorlocked )
end
– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
print( “((destroying scene 1’s view))” )
end
– END OF YOUR IMPLEMENTATION
– “createScene” event is dispatched if scene’s view does not exist
scene:addEventListener( “createScene”, scene )
– “enterScene” event is dispatched whenever scene transition has finished
scene:addEventListener( “enterScene”, scene )
– “exitScene” event is dispatched before next scene’s transition begins
scene:addEventListener( “exitScene”, scene )
– “destroyScene” event is dispatched before view is unloaded, which can be
– automatically unloaded in low memory situations, or explicitly via a call to
– storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( “destroyScene”, scene )
return scene
[/code] [import]uid: 17701 topic_id: 25651 reply_id: 103654[/import]