How do you initiate a fade-out in Corona?

I want the screen to fade to black when my game character reaches the top of the screen, something that starts out with:
if player.y < 50 then--screen fade out[/code]I can think of one way of doing this (by displaying a full-screen, black rectangle and fading it in), but I don't know if this is the simplest method (or best practice). I'm a beginner, so any help would be appreciated.Thank you,Steven [import]uid: 79394 topic_id: 16171 reply_id: 316171[/import]

I guess you need to put all your display objects subject to fade out in a group, then start the transition for this group like this:

[lua]transition.to( myGroup, { time=1000, alpha=0.0 } )[/lua]

This will do the transition of the transparency of all objects in the group from 1.0 (no transparency) to 0.0 (completely transparent)

Don’t forget to clear the objects from memory if you don’t need them any more, to achieve this you can pass the “onComplete” parameter to the table in transition.to() to call a function that does the job

Raúl Beltrán
MIU Games [import]uid: 44101 topic_id: 16171 reply_id: 60171[/import]

Thanks Raul,

I’m going to try using the concept you recommended to transition the black-screen image I was talking about from 1.0 to 0.0, then clear all my display objects once the screen has gone completely black. Hope it works!

Thanks again,
Steven [import]uid: 79394 topic_id: 16171 reply_id: 60387[/import]