ok someone told me that storyboard isn’t being supported anymore and told me i should change to composer. ok i wrote all my codes in storyboard, how would i go about changing it with out affecting my files or changing my design. because im still very new and i dont even still know what the difference between the two are and i was wondering if you could look at my files and tell me what i should do to change them to make them work as a composer or should i just leave it as story board. also could you tell me if im doing any of this wrong.
main.lua file
[lua]
display.setStatusBar( display.HiddenStatusBar )
splashScreen = display.newImage(“Default-568h@2x.png”)
splashScreen.anchorX = 0; splashScreen.anchorY = 0;
– Storyboard
local storyboard = require “storyboard”
storyboard.purgeOnSceneChange = true
storyboard.gotoScene(“splash”)
local loadSave = require “loadsave”
if loadSave.loadTable(“mySaveTable.json”) == nil then
local mySaveTable = {}
mySaveTable.cardIndex = 1
loadSave.saveTable(mySaveTable, “mySaveTable.json”)
end
[/lua]
splashscreen.lua
[lua]
local storyboard = require(“storyboard”)
local scene = storyboard.newScene()
local splashscreen = display.newImage( “zzdirectionquestions.jpg” );
splashscreen.width, splashscreen.height = display.contentWidth, display.contentHeight
splashscreen.x, splashscreen.y = display.contentWidth / 2, display.contentHeight / 2
splashscreen:scale(1.0, .5)
local function removeSplash(event)
splashscreen:removeSelf()
splashscreen = nil
end
timer.performWithDelay(1900,removeSplash)
local text2 = display.newText( “loading…”, 150, 250, native.systemFont, 16 )
text2.x = 165
text2.y = 250
text2:setFillColor(0,0,0)
local function removetext2(event)
text2:removeSelf()
text2 = nil
end
timer.performWithDelay(1000,removetext2)
function scene:createScene(event)
local gameGroup = self.view
_W = display.contentWidth*0.5;
_H = display.contentHeight*0.5;
local background = display.newRect(0,0, display.contentWidth, display.contentHeight)
background.x = _W; background.y = _H;
local text = display.newText( “Continue”, 100, 500, native.systemFont, 20 )
text.x = _W; text.y = _H;
text:setFillColor(0,0,0)
gameGroup:insert(text)
function touchEvent(event)
if event.phase == “ended” then
storyboard.gotoScene(“menuscreen”)
end
end
text:addEventListener(“touch”, touchEvent)
gameGroup:insert(background)
gameGroup:insert(splashscreen)
gameGroup:insert(text)
gameGroup:insert(text2)
splashscreen:toFront()
text2:toFront()
end
function scene:enterScene(event)
end
function scene:exitScene(event)
end
scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)
return scene
[/lua]
menuscreen.lua
[lua]
local storyboard = require(“storyboard”)
local scene = storyboard.newScene()
function scene:createScene(event)
local gameGroup = self.view
local background = display.newImage(“zzfirequestion.jpg”,0,0, display.contentWidth, display.contentHeight)
background.x = 160
background.y = 240
local continueb = display.newText( “>Continue”, 150, 250, native.systemFontBold, 20 )
continueb.x = 165
continueb.y = 200
continueb:setFillColor( 1.0, 0., 0.0 )
continueb:scale(.90,.90)
local resetb = display.newText( “Reset”, 150, 250, native.systemFont, 25 )
resetb.x = 165
resetb.y = 250
resetb:setFillColor( 0.0, 0.9, 0.0 )
resetb:scale(.90,.90)
local aboutb = display.newText( “About”, 150, 250, native.systemFont, 25)
aboutb.x = 165
aboutb.y = 300
aboutb:setFillColor( 0.0, 0.6, 0.9 )
aboutb:scale(.90,.90)
local onTap = function(event)
if event.target == continueb then
storyboard.gotoScene(“gamescreen”)
elseif event.target == resetb then
storyboard.gotoScene(“resetscreen”)
elseif event.target == aboutb then
storyboard.gotoScene(“aboutscreen”)
end
end
continueb:addEventListener(“tap”, onTap)
aboutb:addEventListener(“tap”, onTap)
resetb:addEventListener(“tap”, onTap)
gameGroup:insert(background)
gameGroup:insert(continueb)
gameGroup:insert(resetb)
gameGroup:insert(aboutb)
end
function scene:enterScene(event)
end
function scene:exitScene(event)
end
function scene:destroyScene( event )
end
scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)
return scene
[/lua]
aboutscreen.lua file
[lua]
local storyboard = require(“storyboard”)
local scene = storyboard.newScene()
function scene:createScene(event)
local background = display.newImage(“zzfirequestion.jpg”,0,0, display.contentWidth, display.contentHeight)
background.x = 160
background.y = 240
local gameGroup = self.view
end
function scene:enterScene(event)
end
function scene:exitScene(event)
end
function scene:destroyScene( event )
end
gameGroup:insert(background)
scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)
return scene
end
[/lua]
[lua]
local storyboard = require(“storyboard”)
local scene = storyboard.newScene()
local widget = require (“widget”)
function scene:createScene(event)
local gameGroup = self.view
local loadSave = require “loadsave”
local mySaveTable = loadSave.loadTable(“mySaveTable.json”)
local background = display.newImage(“Default-568h@2x.png”,0,0, display.contentWidth, display.contentHeight)
background.x = 200
background.y = 240
background:scale(.90,1.20)
local function menuTouch(event)
if event.phase == “ended” then
storyboard.gotoScene(“menuscreen”)
end
end
local list_of_things_to_say = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12”, “13”, “14”, “15”, “16”, “17”, “18”, “19”, “20” }
-----display text
local options =
{
--parent = textGroup,
text = “Hello”,
x = 160,
y = 200,
width = 150, --required for multi-line and alignment
font = native.systemFontBold,
fontSize = 18,
align = “center” --new alignment parameter
}
local myText = display.newText( options )
myText:setFillColor( 1, 0, 0 )
– event handler must be defined before creating button with widget.newButton()
local function onObjectTouch( event )
if event.phase == “ended” then
if #list_of_things_to_say > 0 then
– calculate random index
local idx = math.random(1, #list_of_things_to_say)
– set the text property of your text object to the string at given index of list_of_things_to_say
myText.text = list_of_things_to_say[idx]
– remove this string from the table so that it cannot be used again
table.remove(list_of_things_to_say, idx)
else – if there’s no more things to say
myText.text = “No more things to say”
end
end
return true
end
----button
local rndmtxt = widget.newButton
{
left = 160,
top = 410,
id = “newQuestionbtn”,
label = “question me?”,
onEvent = onObjectTouch
}
local menu = widget.newButton
{
left = -25,
top = 410,
id = “menuscreen”,
label = “menu”,
onEvent = menuTouch
}
gameGroup:insert(background)
gameGroup:insert(menu)
gameGroup:insert(rndmtxt)
gameGroup:insert(myText)
end
function scene:enterScene(event)
end
function moveToScene()
end
function scene:exitScene(event)
end
function scene:destroyScene( event )
end
scene:addEventListener(“createScene”, scene)
scene:addEventListener(“enterScene”, scene)
scene:addEventListener(“exitScene”, scene)
scene:addEventListener(“destroyScene”, scene)
return scene
[/lua]