director class not working

Dont know why but this Director:changeScene is not working…but the print"tap" is being printed in the simulator…

[code]
module(…, package.seeall)

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

local image = display.newImageRect( params.image, 1024, 768 )
image.x = 512
image.y = 384
localGroup:insert( image )

local menubtn = display.newImage (“menu.png”)
menubtn.x = display.viewableContentWidth/1.08
menubtn.y = display.viewableContentHeight/1.11
localGroup:insert(menubtn)

local fmenu = function( event )
if event.phase == “ended” then
print(“tap”)
director:changeScene(“menu”)
end
end
menubtn:addEventListener(“touch”,fmenu)

return localGroup
end [import]uid: 82446 topic_id: 16845 reply_id: 316845[/import]

Doesn’t changeScene have the signature as

changeScene(params, nextScene, effect, …)

so wouldn’t your code have to be something like

director:changeScene("",“menu”,"")

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16845 reply_id: 63084[/import]

same problem persists.Now “Tap” is being displayed thrice…
MoreOver there is a Page .lua and one more lua file whose code is
This is basically a sliding image app…

[code]
module(…, package.seeall)

function new()

local localGroup = display.newGroup()

local bgimage = display.newImageRect( “Page01.jpg”, 1024, 768 )
bgimage.x = 512
bgimage.y = 384
localGroup:insert( bgimage )

local showFx

local function createBook ( event )
director:turnToBook ()
director:newBookPages( pageList )
end
showFx = transition.to ( bgimage, { onComplete = createBook } )

return localGroup
end
[import]uid: 82446 topic_id: 16845 reply_id: 63086[/import]

couple things to check

double check case of all files “Menu.png” is different from “menu.png”

and try moving the loadSound code to the main.lua file it will still work on all scenes director doesn’t remove sound files from memory and sometimes loading sound causes a lag [import]uid: 7911 topic_id: 16845 reply_id: 63119[/import]

I have checked it all …It is not showing any error nor changing the scene.shall i post the code? [import]uid: 82446 topic_id: 16845 reply_id: 63934[/import]

Please can anybody help me?My problem is still not resolved.Don’t know what to do.got stuck in the middle… [import]uid: 82446 topic_id: 16845 reply_id: 64843[/import]

looking at code in OP you have new(params)
but you not using pamars in code
are you trying to pass params [import]uid: 7911 topic_id: 16845 reply_id: 64845[/import]

yes i am .Basically params is my variables for the image to be displayed that is

[code]

pageList = {
{ page = “pages”, params = { image = “Page01.jpg” } },
{ page = “pages”, params = { image = “Page02.jpg” } },
{ page = “pages”, params = { image = “Page03.jpg”} },
}
[/code] [import]uid: 82446 topic_id: 16845 reply_id: 64853[/import]

you have your tap printing multiple times, because…

there is something that is causing the menuBtn to *not* be removed, so when you change scenes/pages, a new instance is created and then when you click, you get multiple outputs.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16845 reply_id: 64854[/import]

yes :).But my concern is not printing tap multiple times but the main concern is that I am not getting error also the change scene is not working.Can you help me out please? [import]uid: 82446 topic_id: 16845 reply_id: 64856[/import]

@rahulsingh2k10, I just copied your code, made a quick changes (see the changed code below), and menubtn works just fine. Touching on it changed the scene to menu scene of mine. So, it doesn’t look like fmenu function has any problem. There could be a problem with your menu.lua.

I have no clue how this param.image works. Passing parameter is one of the things I don’t have good grasp on yet (which is a pain in the neck when I need it bad). Anyhow, if nothing else is causing the issue, this param.image could be triggering some sort of problem for you.

Naomi

[lua]module(…, package.seeall)

function new(params)
local screenW = display.contentWidth;
local screenH = display.contentHeight;
local imgWidth;
local imgHeight;

local localGroup = display.newGroup()

imgWidth = 360;
imgHeight = 480;
local image = display.newImageRect( localGroup, “myImage.png”, imgWidth, imgHeight ) ;
image.x = 0.5 * screenW;
image.y = 0.5 * screenH;

– local image = display.newImageRect( params.image, 1024, 768 )
– image.x = 512
– image.y = 384
– localGroup:insert( image )

local menubtn = display.newImage (“myButton.png”)
menubtn.x = display.viewableContentWidth/1.08
menubtn.y = display.viewableContentHeight/1.11
localGroup:insert(menubtn)

local fmenu = function( event )
if event.phase == “ended” then
print(“tap”)
director:changeScene(“menu”)
end
end
menubtn:addEventListener(“touch”,fmenu)

return localGroup
end[/lua] [import]uid: 67217 topic_id: 16845 reply_id: 64878[/import]

Have you try this. Normally if I have object with parameter, I will build a table and use the following method.
local image = display.newImageRect( pagelist[params], 1024, 768 )

please see my sample I normally use.

module(…, package.seeall)

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

local pagelist = {
“page01.jpg”,
“page02.jpg”,
“page03.jpg”,
}

local function displayobject(params)
local image = display.newImageRect( pagelist[params], 1024, 768 )
image.x = 512
image.y = 384
localGroup:insert( image )
print(params)

end

displayobject(3)

local menubtn = display.newImage (“myButton.png”)
menubtn.x = display.viewableContentWidth/1.08
menubtn.y = display.viewableContentHeight/1.11
localGroup:insert(menubtn)

local fmenu = function( event )
if event.phase == “ended” then
print(“tap”)
director:changeScene(“page002”)
end
end
menubtn:addEventListener(“touch”,fmenu)

return localGroup
end
[import]uid: 94613 topic_id: 16845 reply_id: 65181[/import]