[Resolved] Have lil problem with using director class

Hi, I just started using director class in my game i have 2 screens intro and mail but when i try to run it i get this error message:
http://i50.tinypic.com/msiplh.png

What did i do wrong and how to fix it?
[import]uid: 189039 topic_id: 32328 reply_id: 332328[/import]

No info, would need to see code etc. Sounds like you have an error in intro. [import]uid: 52491 topic_id: 32328 reply_id: 128706[/import]

Here is my intro code:

[code]
module ( … , package.seeall )

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

local background = display.newImage(“Basket-ball.jpg”)

local begin = display.newImage(“start_button.png”)
begin.x = 160
begin.y = 400
begin.scene = “main”

introGroup:insert (background)
introGroup:insert (begin)

begin.addEventListener ( “touch” , changeScene )
return introGroup
end[/code]
it was suppose to change scene from intro to main…
or is there way to change from intro to main scene (my game) without using director class?
[import]uid: 189039 topic_id: 32328 reply_id: 128744[/import]

No info, would need to see code etc. Sounds like you have an error in intro. [import]uid: 52491 topic_id: 32328 reply_id: 128706[/import]

Wow that has a few problems…

  1. You add event listener with obj:addEventListener() and NOT obj.addEventListener()

  2. Where is changeScene function defined?

  3. RE 2, are you specifying event.phase in this function? If not it will fire twice. [import]uid: 52491 topic_id: 32328 reply_id: 128815[/import]

Here is my intro code:

[code]
module ( … , package.seeall )

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

local background = display.newImage(“Basket-ball.jpg”)

local begin = display.newImage(“start_button.png”)
begin.x = 160
begin.y = 400
begin.scene = “main”

introGroup:insert (background)
introGroup:insert (begin)

begin.addEventListener ( “touch” , changeScene )
return introGroup
end[/code]
it was suppose to change scene from intro to main…
or is there way to change from intro to main scene (my game) without using director class?
[import]uid: 189039 topic_id: 32328 reply_id: 128744[/import]

Wow that has a few problems…

  1. You add event listener with obj:addEventListener() and NOT obj.addEventListener()

  2. Where is changeScene function defined?

  3. RE 2, are you specifying event.phase in this function? If not it will fire twice. [import]uid: 52491 topic_id: 32328 reply_id: 128815[/import]

ok so i tried changing it abit and this is how my intro.lua looks now still cant get it to change from intro to main… [code]module ( … , package.seeall )

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

local background = display.newImage(“Basket-ball.jpg”)

local begin = display.newImage(“start_button.png”)
begin.x = 160
begin.y = 400
begin.scene = “main”

introGroup:insert (background)
introGroup:insert (begin)

begin:addEventListener ( “touch” , changeScene )
director:changeScene(“main”)
return introGroup

end[/code]
and this is what i put in my main.lua

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")  

in case there is mistake there but it seems i still need to fix something in intro.
can anyone help? Sorry I keep asking a lot of questions but im new to corona sdk

[import]uid: 189039 topic_id: 32328 reply_id: 128988[/import]

ok so i tried changing it abit and this is how my intro.lua looks now still cant get it to change from intro to main… [code]module ( … , package.seeall )

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

local background = display.newImage(“Basket-ball.jpg”)

local begin = display.newImage(“start_button.png”)
begin.x = 160
begin.y = 400
begin.scene = “main”

introGroup:insert (background)
introGroup:insert (begin)

begin:addEventListener ( “touch” , changeScene )
director:changeScene(“main”)
return introGroup

end[/code]
and this is what i put in my main.lua

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")  

in case there is mistake there but it seems i still need to fix something in intro.
can anyone help? Sorry I keep asking a lot of questions but im new to corona sdk

[import]uid: 189039 topic_id: 32328 reply_id: 128988[/import]

I have now changed my main.lua to look like this

[code]local director = require(“director”)

local mainGroup =display.newGroup ( )

local function main ()
mainGroup:insert(director.directorView)
director:changeScene(“intro”)
return true
end

main( )
[/code]and put my game in game.lua thought it would be better to handle it that way and my intro.lua looks like this :

[code]module ( … , package.seeall )

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

local background = display.newImage(“Basket-ball.jpg”)

local begin = display.newImage(“start_button.png”)
begin.x = 160
begin.y = 400
begin.scene = “game”

function changeScene(e)
if ( e.phase == “ended”) then
director:changeScene(e.target.scene)
end
end

introGroup:insert (background)
introGroup:insert (begin)

begin:addEventListener ( “touch” , changeScene )

return introGroup
end
[/code]and it seems it worked thanks for help [import]uid: 189039 topic_id: 32328 reply_id: 129060[/import]

I have now changed my main.lua to look like this

[code]local director = require(“director”)

local mainGroup =display.newGroup ( )

local function main ()
mainGroup:insert(director.directorView)
director:changeScene(“intro”)
return true
end

main( )
[/code]and put my game in game.lua thought it would be better to handle it that way and my intro.lua looks like this :

[code]module ( … , package.seeall )

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

local background = display.newImage(“Basket-ball.jpg”)

local begin = display.newImage(“start_button.png”)
begin.x = 160
begin.y = 400
begin.scene = “game”

function changeScene(e)
if ( e.phase == “ended”) then
director:changeScene(e.target.scene)
end
end

introGroup:insert (background)
introGroup:insert (begin)

begin:addEventListener ( “touch” , changeScene )

return introGroup
end
[/code]and it seems it worked thanks for help [import]uid: 189039 topic_id: 32328 reply_id: 129060[/import]

Glad to hear it - sorry for not jumping back in sooner but we don’t officially support Director and my free time was spent on an airplane yesterday :wink:

Marking as resolved.

Peach :slight_smile:

[import]uid: 52491 topic_id: 32328 reply_id: 129393[/import]

Glad to hear it - sorry for not jumping back in sooner but we don’t officially support Director and my free time was spent on an airplane yesterday :wink:

Marking as resolved.

Peach :slight_smile:

[import]uid: 52491 topic_id: 32328 reply_id: 129393[/import]