storyboard with widget

how do i use storyboard with the widget, i am using a button and trying to make the scene change, i get an error every time i try and the buttton doesn’t go away. If I add the scene = storyboard.newScene() then nothing shows up at all. here is what i have:

[code]


– view2.lua


local widget = require “widget”
local storyboard = require “storyboard”

local onButtonEvent = function (event )
if event.phase == “release” then
print( “You pressed and released a button!” )
storyboard.gotoScene( “view1”, “fade”, 500 )

end
end

local myButton = widget.newButton{
left = 175,
top = 70,
label = “Play”,
width = 150, height = 28,
cornerRadius = 8,
onEvent = onButtonEvent
}

[import]uid: 38977 topic_id: 19429 reply_id: 319429[/import]

View2.lua code seems fine to me. Something is wrong with your View1.lua. Make sure to create a scene in view1.lua and also return it. I can help more once you share view1.lua code.

cheers,
Bejoy [import]uid: 84539 topic_id: 19429 reply_id: 74992[/import]

bejoy, I am trying to make a game similar to age of war, I am using levelhelper also, my view1.lua is this:

[code]


– view1.lua


– hide default status bar (iOS)
display.setStatusBar( display.HiddenStatusBar )
local physics = require( “physics”)
physics.start()

require “LHAnimationsExt”
game = require( “beebegames” )
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
require “LevelHelperLoader”
loader = LevelHelperLoader:initWithContentOfFile(“ageingwar.plhs”)
–path notifiers and event listener for all sprites should be placed here
–see “Collision Handling and Events” and “Beziers” sections for more info
loader:instantiateObjects(physics, camera)
local camera = display.newGroup()
application.LevelHelperSettings.directorGroup = camera
local ground = loader:spriteWithUniqueName(“cloud2”)
local minip = loader:spriteWithUniqueName(“minip”)

camera:insert(ground)


– move camera

local myTouchListener = function( event )
if(event.phase == “began”)then
lastTouchLocation = { x= event.x}
end

if(event.phase == “ended”)then
lastTouchLocation = { x= event.x}
end

if(event.phase == “moved”)then
local delta = { x = event.x - lastTouchLocation.x};
lastTouchLocation = { x= event.x}

camera.x = camera.x + delta.x

end
end
Runtime:addEventListener( “touch”, myTouchListener )

–stop camera

local function stopit(event)
if camera.x < -1030 then
camera.x = -1030
elseif camera.x > 0 then
camera.x = 0
end

end
Runtime:addEventListener(“enterFrame”, stopit)



local function spawn(event)
minip:removeEventListener(“touch”, spawn)
playern = loader:newSpriteWithUniqueName(“player”)
physics.addBody(playern, “dynamic”, {friction=0, bounce=.2, density=.2})
playern:setLinearVelocity(40,0)
playern.x = 46
playern.y = 260

local winner = display.newText(“You WIN”, 200, 100, system.defaultFont, 30)
winner.isVisible = false
local function endit(event)
if playern.x > 100 then
winner.isVisible = true
end
end
playern:addEventListener(“enterFrame”, endit)

local secsText = 3

local timeText = display.newText(secsText, minip.x-5, minip.y-7, “Helvetica”, 24)
timeText:setTextColor(255,255,255)

local function updateTime (event)
secsText = secsText - 1
if secsText == 0 then
timeText:removeSelf()
minip:addEventListener(“touch”, spawn)
end

timeText.text = secsText
end
timer.performWithDelay(1000, updateTime, 0)

end


– first countdown

local secsText = 3
local timeText = display.newText(secsText, minip.x-5, minip.y-7, “Helvetica”, 24)
timeText:setTextColor(255,255,255)

local function updateTime (event)
secsText = secsText - 1
if secsText == 0 then
timeText:removeSelf()
minip:addEventListener(“touch”, spawn)
end

timeText.text = secsText
end
timer.performWithDelay(1000, updateTime, 0)

local mRand1 = math.random(4000, 5000)
local function spawnc(event)

enemy = loader:newSpriteWithUniqueName(“gb_walk_12”)
physics.addBody(enemy, “dynamic”, {friction=0, bounce=.2, density=.2})
enemy:setLinearVelocity(-40,0)
enemy.x = 1500
enemy.y = 250

end
timer.performWithDelay(mRand1, spawnc, 9999999999999)



return scene [import]uid: 38977 topic_id: 19429 reply_id: 75137[/import]

Gigabook - You view1 does not have the storyboard event declaration(enterScene, ExitScene).

Please use this template for more information regarding using storyboard.

http://developer.anscamobile.com/reference/index/scene-template [import]uid: 84539 topic_id: 19429 reply_id: 75150[/import]