[Resolved] menus in the menu.lua

@peach pellen

It works now. Thanks. [import]uid: 128294 topic_id: 30330 reply_id: 123652[/import]

If you post code I may be able to assist depending on how bulky it is- this is a Director error so would normally go in Director sub forum but if your code is fairly clean I don’t mind skimming it - my guess is it’s in the first or last few lines of levels.lua or level1.lua based on the above error. [import]uid: 52491 topic_id: 30330 reply_id: 123336[/import]

@peach pellen

Does this code look clean? Thought it wouldn’t look too messy.
levels.lua

[lua]module(…, package.seeall)

function new()
local localGroup = display.newGroup()

local background = display.newImage (“mainbackground.jpg”)
localGroup:insert(background)

local level1btn = display.newImage (“level1btn.png”)
level1btn.x = 160
level1btn.y = 200
localGroup:insert(level1btn)

local menubutton = display.newImage (“backbutton.png”)
menubutton.x = 160
menubutton.y = 350
localGroup:insert(menubutton)
local function pressLevel1 (event)
if event.phase == “ended” then
director:changeScene (“level1”)
end
end

level1btn:addEventListener (“touch”, pressLevel1)
local function pressMenubutton (event)
if event.phase == “ended” then
director:changeScene (“menu”)
end
end

menubutton:addEventListener (“touch”, pressMenu)

return localGroup
end[/lua]

and for level1

[lua]module(…, package.seeall)

function new()
local localGroup = display.newGroup()

local background = display.newImage (“mainbackground.jpg”)
localGroup:insert(background)

local level1btn = display.newImage (“level1btn.png”)
level1btn.x = 160
level1btn.y = 200
localGroup:insert(level1btn)

local menubutton = display.newImage (“backbutton.png”)
menubutton.x = 160
menubutton.y = 350
localGroup:insert(menubutton)
local function pressLevel1 (event)
if event.phase == “ended” then
director:changeScene (“level1”)
end
end

level1btn:addEventListener (“touch”, pressLevel1)
local function pressMenubutton (event)
if event.phase == “ended” then
director:changeScene (“menu”)
end
end

menubutton:addEventListener (“touch”, pressMenu)

return localGroup
end[/lua]

Thought I’d just stick with 1 button.
[import]uid: 128294 topic_id: 30330 reply_id: 123339[/import]

That actually looks OK at a glance - nothing stands out as being an issue.

If you are happy to upload this as a zip, or provide plug and play, then I’d be happy to try and make a little time tomorrow to see if I can help you isolate the problem. [import]uid: 52491 topic_id: 30330 reply_id: 123363[/import]

@peach pellen how do you feel about email? [import]uid: 128294 topic_id: 30330 reply_id: 123370[/import]

If you want to email me just your project file (or a cut down version etc) I am happy to take a look and reply here in the thread but wont be able to go back and forth via email - OK?

If that suits - peach[at]coronalabs :slight_smile: [import]uid: 52491 topic_id: 30330 reply_id: 123488[/import]

@peach pellen

Then I will email you the files. [import]uid: 128294 topic_id: 30330 reply_id: 123494[/import]

levels.lua line 37;
[lua]menubutton:addEventListener (“touch”, pressMenu)[/lua]
Should be;
[lua]menubutton:addEventListener (“touch”, pressMenubutton)[/lua]

level1.lua line 16;
[lua]director:changeScene (“levelsn”)[/lua]
Should be;
[lua]director:changeScene (“levels”)[/lua]

level1.lua line 20;
[lua]backbutton:addEventListener (“touch”, pressBack)[/lua]
Should be;
[lua]backbutton:addEventListener (“touch”, pressBackbutton)[/lua]

That will fix it.

Peach :slight_smile: [import]uid: 52491 topic_id: 30330 reply_id: 123640[/import]

@peach pellen

It works now. Thanks. [import]uid: 128294 topic_id: 30330 reply_id: 123652[/import]