function changeScene(e) errors

i dont get this no matter how i do this it will not run work without an error

function changeScene(e) if (e.phase == "ended") then director:changeScene(e.target.scene) end end local director = require("director") local mainGroup = display.newGroup() mainGroup:insert(director.directorView) director:changeScene("intro")

local background = display.newImage("graphics/backaround.png") local title = display.newImage("graphics/title.png") title.x = 160 title.y = 150 local play = display.newImage("graphics/play.png") play.x = 160 play.y = 300 local options = display.newImage("graphics/options.png") options.x = 160 options.y = 350 local credits = display.newImage("graphics/credits.png") credits.x = 160 credits.y = 400

Is the 2nd block of code supposed to represent your intro.lua Director scene?  If so, it’s not formatted like a director scene should be.  At a minimum you need this structure:

module(..., package.seeall) function new(params)     local localGroup = display.newGroup()   -- all your scene code here.       function clean()         -- any clean up code here.     end     return localGroup end

And every thing you create like background, credits, play, etc. need to be inserted into localGroup like:

    localGroup:insert(background)

Without that base code, Director cannot deal with your scene and will through errors.

Is the 2nd block of code supposed to represent your intro.lua Director scene?  If so, it’s not formatted like a director scene should be.  At a minimum you need this structure:

module(..., package.seeall) function new(params)     local localGroup = display.newGroup()   -- all your scene code here.       function clean()         -- any clean up code here.     end     return localGroup end

And every thing you create like background, credits, play, etc. need to be inserted into localGroup like:

    localGroup:insert(background)

Without that base code, Director cannot deal with your scene and will through errors.