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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-----------------------------------------------------------------------------------------
--
-- 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
    }

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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
-----------------------------------------------------------------------------------------
--
-- 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

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

views:1478 update:2011/12/29 9:44:01
corona forums © 2003-2011