main.lua - button function doesnt work...

I have no clue what i’m doing wrong… i get a black screen. im trying to make a button on the main.lua, and when you touch it - it bring you over to game.lua

[code]
display.setStatusBar( display.HiddenStatusBar )

local startground = display.newImage ( “colorfull.png” )

function new ()

local localGroup = display.newGroup()

_W = display.contentWidth
_H = display.contentHeight

velocity = 70
halfpoint = 0

local start = display.newImageRect(“start_button.png”, _W/10,75)
back:setReferencePoint(display.CenterReferencePoint)
start.x = _240
start.y = _160
localGroup:insert(start)

function changeScene(e)

if (e.phase == “ended”) then
director:changeScene(“game”)

end

end

back:addEventListener(“touch”, changeScene)
[/code] [import]uid: 170560 topic_id: 29758 reply_id: 329758[/import]

Hey @tambovskya ,
Tell me where are you declaring your “back” object to be also adding an eventListener to it? Honestly I cannot see it on the code posted above.

So, what I would suggest you to see maybe this code working is that you change the line:

[lua]back:addEventListener(“touch”, changeScene)[/lua] to [lua]start:addEventListener(“touch”, changeScene)[/lua]

Let me know how it goes.
Cheers,
Rodrigo. [import]uid: 89165 topic_id: 29758 reply_id: 119403[/import]

Hey, thanks for the quick response. It seems that I might have just written the wrong code from the start.

I need a button on the main.lua to open game.lua when clicked. It’s a image button_image.png. Thanks. [import]uid: 170560 topic_id: 29758 reply_id: 119404[/import]