The errors are all coming from the director. You aren’t using it correctly here is a link to the video tutorial.
Your main.lua file should look like this
[lua]local director = require(“director”);
local mainGroup = display.newGroup();
local function main()
mainGroup:insert(director.directorView);
–Whatever screen you want it to change to.
director:changeScene("");
return true;
end
main()[/lua]
And you other file should look like this
[lua]module(…, package.seeall)
_W = display.contentWidth
_H = display.contentHeight
–> Adding physics engine
local physics = require(“physics”)
physics.start()
–> Set gravity to act down
physics.setGravity(0, 9.8)
–> Hide status bar on display
display.setStatusBar( display.HiddenStatusBar )
function new()
local localGroup = display.newGroup();
–> Add background image
local background = display.newImage(“backgrounds/background_01_01.png”)
localGroup:insert(background)
–> Add pillow image
local pillow = display.newImage(“resources/pillow.png”)
pillow.x = display.contentWidth/1.95
pillow.y = display.contentHeight/1.12
localGroup:insert(pillow)
—> Turn pillow into physics body
physics.addBody(pillow, “static”, { bounce = 0.2} )
–> Add piggy image
local piggy = display.newImage(“resources/piggy_player.png”)
piggy.x = display.contentWidth/2
piggy.y = display.contentHeight/8
localGroup:insert(piggy)
—> Turn piggy into physics body
physics.addBody(piggy, { bounce = 0.2})
–> Add candy01 image
local candy01 = display.newImage(“game_candy/candy02.png”)
candy01.x = display.contentWidth/2
candy01.y = display.contentHeight/3.2
localGroup:insert(candy01)
–> Turn candy01 into physics body
physics.addBody(candy01, “static”, { bounce = 0.1})
–> Add tut01 image
local tut01 = display.newImage(“resources/tut01.png”)
tut01.x = display.contentWidth/1.285
tut01.y = display.contentHeight/2.35
localGroup:insert(tut01)
–> Add tut02 image
local tut02 = display.newImage(“resources/tut02.png”)
tut02.x = display.contentWidth/5
tut02.y = display.contentHeight/1.34
localGroup:insert(tut02)
–> Add tut03 image
local tut03 = display.newImage(“resources/tut03.png”)
tut03.x = display.contentWidth/1.305
tut03.y = display.contentHeight/1.34
localGroup:insert(tut03)
–> Add object_01_01(ice-cream) image
local object_01_01 = display.newImage(“game_objects/object_01_01.png”)
object_01_01.x = display.contentWidth/2
object_01_01.y = display.contentHeight/1.33
localGroup:insert(object_01_01)
–> Add level1_headerTitle image
local level1_headerTitle = display.newImage(“resources/level1_headerTitle.png”)
level1_headerTitle.x = display.contentWidth/11
level1_headerTitle.y = display.contentHeight/19
localGroup:insert(level1_headerTitle)
–> Add menu button
local button = display.newImage( “resources/buttonMenuExit.png” )
button.x = display.contentWidth/14
button.y = display.contentHeight/1.1
localGroup:insert(button)
function Button(event)
local phase = event.phase
if “began” == phase then
director:changeScene (“levelOne”)
end
end
button = display.newRect( 0, 0, _W, _H)
button.x = _W * 0.5;
button.y = _H * 0.5;
button:setFillColor(0, 0, 0, 0)
localGroup:insert(button)
button:addEventListener( “touch”, Button )
–> Function that calls destruction on click
function deleteMe(event)
local targetObj = event.target
targetObj:removeSelf()
end
–> Objects that needs to be destroyed on click, add here
candy01:addEventListener(“touch”, deleteMe)
tut01:addEventListener(“touch”, deleteMe)
tut02:addEventListener(“touch”, deleteMe)
tut03:addEventListener(“touch”, deleteMe)
return localGroup
end[/lua]
Make sure all your other files that you are going to use with the Director look like that.
Also,you have two display objects called buttons, so either take one out or change its name. [import]uid: 17138 topic_id: 13071 reply_id: 48083[/import]