Help Storyboard Error

Hello everybody,

I’ve a question. I want to go with the Single Player button to sp.lua and that works. But if I click on the Back or Start button in sp.lua nothing happens. Can you please help me?

Greetz Borisbroekie

–MAIN.LUA–

local storyboard = require “storyboard”
local scene = storyboard.newScene()

local widget = require “widget”
display.setStatusBar( display.HiddenStatusBar )

local background = display.newImage ( “SkySoccer Grass.jpg” )

local ball = display.newImage( “SkySoccer Ball.gif” )
ball.x = display.contentWidth / 2

local white = display.newImage( “witteachtergrond.png” )
white.x = display.contentWidth / 1.3
white.y = display.contentWidth / 25

local myText = display.newText( “SkySoccer”, 0, 0, native.systemFont, 50 )
myText.x = display.contentCenterX
myText.y = display.contentWidth / 4.5
myText:setTextColor( 255, 0, 0 )

local myText = display.newText( “BroekieNetwork”, 0, 0, native.systemFont, 20 )
myText.x = display.contentWidth / 1.3
myText.y = display.contentWidth / 25
myText:setTextColor( 0, 0, 255 )

local function onButtonRelease( event )
local btn = event.target
storyboard.gotoScene( “sp” )
end

local button = widget.newButton{
id = “singleplayer”,
default = “single player.png”,
over = “single player2.png”,
onRelease = onButtonRelease
}
button.x = display.contentCenterX
button.y = display.contentWidth / 2

local function onButtonRelease2( event )
local btn = event.target
storyboard.gotoScene( “mp”, “fade”, 500 )
end

local button = widget.newButton{
id = “multiplayer”,
default = “multiplayer.png”,
over = “multiplayer2.png”,
onRelease = onButtonRelease2
}
button.x = display.contentCenterX
button.y = display.contentWidth / 1.4

local function onButtonRelease3( event )
local btn = event.target
storyboard.gotoScene( “pm”, “fade”, 500 )
end

local button = widget.newButton{
id = “promode”,
default = “pro mode.png”,
over = “pro mode2.png”,
onRelease = onButtonRelease3
}
button.x = display.contentCenterX
button.y = display.contentWidth / 1.07

local function onButtonRelease4( event )
local btn = event.target
storyboard.gotoScene( “tbm”, “fade”, 500 )
end

local button = widget.newButton{
id = “twoballsmode”,
default = “two balls mode.png”,
over = “two balls mode2.png”,
onRelease = onButtonRelease4
}
button.x = display.contentCenterX
button.y = display.contentWidth / 0.87

local function onButtonRelease5( event )
local btn = event.target
storyboard.gotoScene( “s”, “fade”, 500 )
end

local button = widget.newButton{
id = “shop”,
default = “shop.png”,
over = “shop2.png”,
onRelease = onButtonRelease5
}
button.x = display.contentCenterX
button.y = display.contentWidth / 0.73

–SP.LUA–

local storyboard = require “storyboard”
local scene = storyboard.newScene()

local widget = require “widget”
display.setStatusBar( display.HiddenStatusBar )

local background = display.newImage ( “uitlegbg.jpg” )

local myText = display.newText( “Single Player”, 0, 0, native.systemFont, 40 )
myText.x = display.contentCenterX
myText.y = display.contentWidth / 10
myText:setTextColor( 255, 0, 0 )

local myText = display.newRetinaText( “You have one ball and you have to keep the ball high as many times as you can”, 30, 70, 280, 220, native.systemFont, 22 )
myText:setTextColor( 255, 0, 0 )

local road = display.newImage( “roadklein.jpg” )
road.x = display.contentWidth / 5.5
road.y = display.contentWidth / 1.5

local beach = display.newImage( “beachklein.jpg” )
beach.x = display.contentWidth / 1.97
beach.y = display.contentWidth / 1.5

local house = display.newImage( “houseklein.jpg” )
house.x = display.contentWidth / 1.2
house.y = display.contentWidth / 1.5

local park = display.newImage( “parkklein.jpg” )
park.x = display.contentWidth / 3.3
park.y = display.contentWidth / 0.95

local stadium = display.newImage( “stadiumklein.jpg” )
stadium.x = display.contentWidth / 1.4
stadium.y = display.contentWidth / 0.95

local button = widget.newButton{
id = “back”,
default = “back.png”,
over = “back2.png”,
onEvent = onButtonRelease
}
button.x = display.contentWidth / 4.2
button.y = display.contentWidth / 0.73

local function onButtonRelease( event )
local btn = event.target
storyboard.gotoScene( “main” )
end

local button = widget.newButton{
id = “start”,
default = “start.png”,
over = “start2.png”,
onRelease = onButtonRelease2
}
button.x = display.contentWidth / 1.3
button.y = display.contentWidth / 0.73

local function onButtonRelease2( event )
local btn = event.target
storyboard.gotoScene( “spstart”, “fade”, 500 )
end [import]uid: 203192 topic_id: 34013 reply_id: 334013[/import]

Change:

[lua]local button = widget.newButton{
id = “back”,
default = “back.png”,
over = “back2.png”,
onEvent = onButtonRelease
}
button.x = display.contentWidth / 4.2
button.y = display.contentWidth / 0.73

local function onButtonRelease( event )
local btn = event.target
storyboard.gotoScene( “main” )
end

local button = widget.newButton{
id = “start”,
default = “start.png”,
over = “start2.png”,
onRelease = onButtonRelease2
}
button.x = display.contentWidth / 1.3
button.y = display.contentWidth / 0.73

local function onButtonRelease2( event )
local btn = event.target
storyboard.gotoScene( “spstart”, “fade”, 500 )
end[/lua]

to

[lua]local function onButtonRelease( event )
local btn = event.target
storyboard.gotoScene( “main” )
end
local button = widget.newButton{
id = “back”,
default = “back.png”,
over = “back2.png”,
onEvent = onButtonRelease
}
button.x = display.contentWidth / 4.2
button.y = display.contentWidth / 0.73

local function onButtonRelease2( event )
local btn = event.target
storyboard.gotoScene( “spstart”, “fade”, 500 )
end

local button = widget.newButton{
id = “start”,
default = “start.png”,
over = “start2.png”,
onRelease = onButtonRelease2
}
button.x = display.contentWidth / 1.3
button.y = display.contentWidth / 0.73[/lua] [import]uid: 147305 topic_id: 34013 reply_id: 135285[/import]

Thanx that helped! Now I can go from sp.lua to spstart.lua
BUT I still can’t go from sp.lua back to main.lua

Can you help me with that problem please? [import]uid: 203192 topic_id: 34013 reply_id: 135328[/import]

You should be able to but that’s a lot of unformatted code so maybe something else is off. try adding

[lua]
print(“Going to main”) [/lua]

to your function that switches to your main scene. After you press the button check the console to see if you got the going to main. We are just checking to see if that event is firing.

Btw the problem was that you defined your onButtonRelease events after you created the button. That being the case no event was being fired(at least any events you defined anyway). [import]uid: 147305 topic_id: 34013 reply_id: 135333[/import]

Change:

[lua]local button = widget.newButton{
id = “back”,
default = “back.png”,
over = “back2.png”,
onEvent = onButtonRelease
}
button.x = display.contentWidth / 4.2
button.y = display.contentWidth / 0.73

local function onButtonRelease( event )
local btn = event.target
storyboard.gotoScene( “main” )
end

local button = widget.newButton{
id = “start”,
default = “start.png”,
over = “start2.png”,
onRelease = onButtonRelease2
}
button.x = display.contentWidth / 1.3
button.y = display.contentWidth / 0.73

local function onButtonRelease2( event )
local btn = event.target
storyboard.gotoScene( “spstart”, “fade”, 500 )
end[/lua]

to

[lua]local function onButtonRelease( event )
local btn = event.target
storyboard.gotoScene( “main” )
end
local button = widget.newButton{
id = “back”,
default = “back.png”,
over = “back2.png”,
onEvent = onButtonRelease
}
button.x = display.contentWidth / 4.2
button.y = display.contentWidth / 0.73

local function onButtonRelease2( event )
local btn = event.target
storyboard.gotoScene( “spstart”, “fade”, 500 )
end

local button = widget.newButton{
id = “start”,
default = “start.png”,
over = “start2.png”,
onRelease = onButtonRelease2
}
button.x = display.contentWidth / 1.3
button.y = display.contentWidth / 0.73[/lua] [import]uid: 147305 topic_id: 34013 reply_id: 135285[/import]

Thanx that helped! Now I can go from sp.lua to spstart.lua
BUT I still can’t go from sp.lua back to main.lua

Can you help me with that problem please? [import]uid: 203192 topic_id: 34013 reply_id: 135328[/import]

You should be able to but that’s a lot of unformatted code so maybe something else is off. try adding

[lua]
print(“Going to main”) [/lua]

to your function that switches to your main scene. After you press the button check the console to see if you got the going to main. We are just checking to see if that event is firing.

Btw the problem was that you defined your onButtonRelease events after you created the button. That being the case no event was being fired(at least any events you defined anyway). [import]uid: 147305 topic_id: 34013 reply_id: 135333[/import]