I have a question about Changing Scene

I have a problem about changing scene.

After I add the touch function (gotoScene) to the start_btn, but no matter where i tapped in the simulator, it goes to the game scene. 

(What i want is to change scene, only when i tap the start_btn)

Can anyone help me with this problem?

 
Here is my start.lua

[lua]local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

local w = display.contentWidth
local h = display.contentHeight
local cx = display.contentCenterX
local cy = display.contentCenterY


function startGame (event)

if event.phase == “ended” then
storyboard.gotoScene (“game”)

end

end

function scene:createScene( event )

local screenGroup = self.view

start_btn = display.newImageRect (“PressStart.png”, 900, 700)
start_btn.x = cx - -18
start_btn.y = cy - -55
screenGroup:insert(start_btn)

end

function scene:enterScene( event )

start_btn:addEventListener (“touch”, startGame)

end

scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )

return scene[/lua]

And here is my game.lua

[lua]local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

return scene[/lua]

Is your button really 900x700 pixels?  What is your content area defined as in your config.lua?

Thanks

Rob

This is my config.lua file and I dont think my start_btn is 900 x 700 pixels.

would it be ok? if i make a new one ( i mean smaller start_btn ) in photoshop

[lua]if ( string.sub( system.getInfo(“model”), 1, 4 ) == “iPad” ) then
application =
{
content =
{
width = 360,
height = 480,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}

elseif ( string.sub( system.getInfo(“model”), 1, 2 ) == “iP” and display.pixelHeight > 960 ) then
application =
{
content =
{
width = 320,
height = 568,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}

elseif ( string.sub( system.getInfo(“model”), 1, 2 ) == “iP” ) then
application =
{
content =
{
width = 320,
height = 480,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}

elseif ( display.pixelHeight / display.pixelWidth > 1.72 ) then
application =
{
content =
{
width = 320,
height = 570,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}

else
application =
{
content =
{
width = 320,
height = 512,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}

end[/lua]

start_btn = display.newImageRect (“PressStart.png”, 900, 700)

That is creating an image, using PressStart.png that is 900px wide x 700px high

Rob

Is your button really 900x700 pixels?  What is your content area defined as in your config.lua?

Thanks

Rob

This is my config.lua file and I dont think my start_btn is 900 x 700 pixels.

would it be ok? if i make a new one ( i mean smaller start_btn ) in photoshop

[lua]if ( string.sub( system.getInfo(“model”), 1, 4 ) == “iPad” ) then
application =
{
content =
{
width = 360,
height = 480,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}

elseif ( string.sub( system.getInfo(“model”), 1, 2 ) == “iP” and display.pixelHeight > 960 ) then
application =
{
content =
{
width = 320,
height = 568,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}

elseif ( string.sub( system.getInfo(“model”), 1, 2 ) == “iP” ) then
application =
{
content =
{
width = 320,
height = 480,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}

elseif ( display.pixelHeight / display.pixelWidth > 1.72 ) then
application =
{
content =
{
width = 320,
height = 570,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}

else
application =
{
content =
{
width = 320,
height = 512,
scale = “letterBox”,
xAlign = “center”,
yAlign = “center”,
imageSuffix =
{
["@2x"] = 1.5,
["@4x"] = 3.0,
},
},
}

end[/lua]

start_btn = display.newImageRect (“PressStart.png”, 900, 700)

That is creating an image, using PressStart.png that is 900px wide x 700px high

Rob