Fade out menu screen

I’m having a little trouble with transitioning from my menu screen to the next game option.
My menu screen and buttons fade in using transition.to, and when one of the buttons is pressed, I want the background to fade to white, the buttons to fade, and the new scene to load.

I can get the display objects to fade when a button is pressed, but I can’t figure out how to make the scene change after my screen fades to white.
I have tried using a timer:performWithDelay but to no avail.

Any ideas?

Some of my code below:

[code]

local colorsbtn = display.newImageRect(“images/colorbtn.png”, 121, 121)
colorsbtn:setReferencePoint(display.CenterReferencePoint)
colorsbtn.x =440 ; colorsbtn.y=295
colorsbtn.alpha=0
transition.to(colorsbtn, {time=1000, y=295, x=240, alpha=1})
colorsbtn.scene = “colors”

local flashbtn = display.newImageRect(“images/flashcardbtn.png”, 121, 121)
flashbtn:setReferencePoint(display.CenterReferencePoint)
flashbtn.x =-120 ; flashbtn.y=420
flashbtn.alpha=0
transition.to(flashbtn, {time=1000, y=420, x=80, alpha=1})
flashbtn.scene = “flash”
local whiteFadeout = function(event)
director:changeScene(e.target.scene)
end

local function changeScene(e)
if(e.phase==“ended” or e.phase==“cancelled”)then
transition.to(bg_frame, {time=1000, alpha=0}) – fades out background artwork
transition.to(whiteback, {time=500, alpha=1}) – fades in white background

transition.to(flashbtn, {time=1000, alpha=0}) – fades out flashbtn
transition.to(colorsbtn, {time=1000, alpha=0}) – fades out colorsbtn

timer:performWithDelay (1000, whiteFadeout)
end
end

[/code] [import]uid: 92074 topic_id: 16874 reply_id: 316874[/import]

It should be timer.performWithDelay, in case that was your issue.

If you want to use director to change scenes with a delay to this;

[lua]local function changeScene ()
director:changeScene(“sceneName”)
end
timer.performWithDelay(1000, changeScene, 1)[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 16874 reply_id: 63222[/import]