module(..., package.seeall) function new() local localGroup = display.newGroup(); local back = display.newImageRect("images/back.png", \_W, \_H); back:setReferencePoint(display.CenterReferencePoint); back.x = \_W/2; back.y = \_H/2; back.scene = "menu"; localGroup:insert(back); function changeScene(e) if(e.phase == "ended") then dictector:changeScene(e.target.scene); end end back:addEventListener("touch", changeScene); return localGroup; end
\_W = display.contentWidth; \_H = display.contentHeight; local director = require("director"); local mainGroup = display.newGroup(); local function main() mainGroup:insert(director.directorView); director:changeScene("menu"); return true; end main();
module(..., package.seeall) function new() local localGroup = display.newGroup(); local bg = display.newImageRect("images/bg.png", \_W, \_H); bg:setReferencePoint(display.CenterReferencePoint); bg.x = \_W/2; bg.y = \_H/2; local title = display.newImageRect("images/title.png", \_W, 132); title:setReferencePoint(display.CenterReferencePoint); title.x = \_W/2; title.y = title.height; function changeScene(e) if(e.phase == "ended") then director:changeScene(e.target.scene); end end local play\_btn = display.newImageRect("images/play-btn.png", \_W, 75); play\_btn:setReferencePoint(display.CenterReferencePoint); play\_btn.x = \_W/2; play\_btn.y = \_H/2 + play\_btn.height; play\_btn.scene = "game"; local credits\_btn = display.newImageRect("images/credits-btn.png", \_W, 75); credits\_btn:setReferencePoint(display.CenterReferencePoint); credits\_btn.x = \_W/2; credits\_btn.y = \_H/2 + play\_btn.height + credits\_btn.height; credits\_btn.scene = "credits"; localGroup:insert(bg); localGroup:insert(title); localGroup:insert(play\_btn); localGroup:insert(credits\_btn); play\_btn:addEventListener("touch", changeScene); credits\_btn:addEventListener("touch", changeScene); return localGroup; end
for some reason i am getting an error “director.lua:1092: attempt to call method '‘insert’ (a nil value) stack traceback: [c]; in function ‘insert’ director.lua1092; in function ‘changeScene’ main.lua:16 menu.lua:14 ?:in function <?:218>”