[lua]local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view
local bg = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bg:setFillColor( 0 )
if silverkey == 1 then
local title = display.newText( “You are in what appears to be the master bedroom. The king-sized bed frame is all that’s left. The grand window on the north side overlooks the ocean. A small island can been seen in the distance.\n\nExits lead South and East.”, 0, 0, 320, 500, native.systemFont, 16 )
title:setTextColor( r, g, b )
else
local title = display.newText( “You are in what appears to be the master bedroom. The king-sized bed frame is all that’s left. The grand window on the north side overlooks the ocean. A small island can been seen in the distance.\n\nThere is a key here.\n\nExits lead South and East.”, 0, 0, 320, 500, native.systemFont, 16 )
title:setTextColor( r, g, b )
end
local northbutton = display.newRect(0, 0, 76, 30, 4)
northbutton.strokeWidth = 2
northbutton:setFillColor(0)
northbutton.x = display.contentWidth / 2
northbutton.y = display.contentHeight - 160
local ntitle = display.newText( “North”, 0, 0, native.systemFont, 16 )
ntitle:setTextColor( 255, 255, 255 )
ntitle:setReferencePoint( display.CenterReferencePoint )
ntitle.x = display.contentWidth / 2
ntitle.y = display.contentHeight - 160
function northbutton:tap( event )
local alert = native.showAlert( “You can’t go that way.”, “”, { “OK” },
onComplete )
end
northbutton:addEventListener( “tap”, northbutton )
local southbutton = display.newRect(0, 0, 76, 30, 4)
southbutton.strokeWidth = 2
southbutton:setFillColor(0)
southbutton.x = display.contentWidth / 2
southbutton.y = display.contentHeight - 55
local stitle = display.newText( “South”, 0, 0, native.systemFont, 16 )
stitle:setTextColor( 255, 255, 255 )
stitle:setReferencePoint( display.CenterReferencePoint )
stitle.x = display.contentWidth / 2
stitle.y = display.contentHeight - 55
function southbutton:tap( event )
storyboard.gotoScene( “room2” )
end
southbutton:addEventListener( “tap”, southbutton )
local westbutton = display.newRect(0, 0, 76, 30, 4)
westbutton.strokeWidth = 2
westbutton:setFillColor(0)
westbutton.x = display.contentWidth / 3
westbutton.y = display.contentHeight - 110
local wtitle = display.newText( “West”, 0, 0, native.systemFont, 16 )
wtitle:setTextColor( 255 )
wtitle:setReferencePoint( display.CenterReferencePoint )
wtitle.x = display.contentWidth / 3
wtitle.y = display.contentHeight - 110
function westbutton:tap( event )
local alert = native.showAlert( “You can’t go that way.”, “”, { “OK” },
onComplete )
end
westbutton:addEventListener( “tap”, westbutton )
local eastbutton = display.newRect(0, 0, 76, 30, 4)
eastbutton.strokeWidth = 2
eastbutton:setFillColor(0)
eastbutton.x = display.contentWidth / 1.5
eastbutton.y = display.contentHeight - 110
local etitle = display.newText( “East”, 0, 0, native.systemFont, 16 )
etitle:setTextColor( 255 )
etitle:setReferencePoint( display.CenterReferencePoint )
etitle.x = display.contentWidth / 1.5
etitle.y = display.contentHeight - 110
function eastbutton:tap( event )
storyboard.gotoScene( “room4” )
end
eastbutton:addEventListener( “tap”, eastbutton )
local upbutton = display.newRect(0, 0, 76, 30, 4)
upbutton.strokeWidth = 2
upbutton:setFillColor(0)
upbutton.x = display.contentWidth / 1.2
upbutton.y = display.contentHeight - 180
local utitle = display.newText( “Up”, 0, 0, native.systemFont, 16 )
utitle:setTextColor( 255 )
utitle:setReferencePoint( display.CenterReferencePoint )
utitle.x = display.contentWidth / 1.2
utitle.y = display.contentHeight - 180
function upbutton:tap( event )
local alert = native.showAlert( “You can’t go that way.”, “”, { “OK” },
onComplete )
end
upbutton:addEventListener( “tap”, upbutton )
local downbutton = display.newRect(0, 0, 76, 30, 4)
downbutton.strokeWidth = 2
downbutton:setFillColor(0)
downbutton.x = display.contentWidth / 1.2
downbutton.y = display.contentHeight - 35
local dtitle = display.newText( “Down”, 0, 0, native.systemFont, 16 )
dtitle:setTextColor( 255 )
dtitle:setReferencePoint( display.CenterReferencePoint )
dtitle.x = display.contentWidth / 1.2
dtitle.y = display.contentHeight - 35
function downbutton:tap( event )
local alert = native.showAlert( “You can’t go that way.”, “”, { “OK” },
onComplete )
end
downbutton:addEventListener( “tap”, downbutton )
local asbutton = display.newRect(0, 0, 76, 30, 4)
asbutton.strokeWidth = 2
asbutton:setFillColor(0)
asbutton.x = display.contentWidth / 5.8
asbutton.y = display.contentHeight - 180
local astitle = display.newText( “Assests”, 0, 0, native.systemFont, 16 )
astitle:setTextColor( 255 )
astitle:setReferencePoint( display.CenterReferencePoint )
astitle.x = display.contentWidth / 5.8
astitle.y = display.contentHeight - 180
function asbutton:tap( event )
local alert = native.showAlert( inv, “”, { “OK” },
onComplete )
end
asbutton:addEventListener( “tap”, asbutton )
local morebutton = display.newRect(0, 0, 76, 30, 4)
morebutton.strokeWidth = 2
morebutton:setFillColor(0)
morebutton.x = display.contentWidth / 5.8
morebutton.y = display.contentHeight - 35
local moretitle = display.newText( “More”, 0, 0, native.systemFont, 16 )
moretitle:setTextColor( 255 )
moretitle:setReferencePoint( display.CenterReferencePoint )
moretitle.x = display.contentWidth / 5.8
moretitle.y = display.contentHeight - 35
function morebutton:tap( event )
storyboard.gotoScene( “room1_2” )
end
morebutton:addEventListener( “tap”, morebutton )
– all objects must be added to group (e.g. self.view)
group:insert( bg )
group:insert( title )
group:insert( northbutton )
group:insert( ntitle )
group:insert( southbutton )
group:insert( stitle )
group:insert( westbutton )
group:insert( wtitle )
group:insert( eastbutton )
group:insert( etitle )
group:insert( upbutton )
group:insert( utitle )
group:insert( downbutton )
group:insert( dtitle )
group:insert( asbutton )
group:insert( astitle )
group:insert( morebutton )
group:insert( moretitle )
end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view
– Do nothing
end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view
– INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.)
end
– If scene’s view is removed, scene:destroyScene() will be called just prior to:
function scene:destroyScene( event )
local group = self.view
– INSERT code here (e.g. remove listeners, remove widgets, save state variables, etc.)
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 whenever 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[/lua]
I’m setting the silverkey and r, g and b variables in the main.lua.
[import]uid: 115085 topic_id: 24679 reply_id: 99994[/import]