"Fade" doesn't work

Hi, there! I have only began to code. 1st problem - why doesn’t “fade” work?? 

Don’t with this code

local composer = require (“composer”)

local options = {

    effect = “fade”,

    time = 800,

}

composer.gotoScene(“start”, options)

and don’t with this

local composer = require (“composer”)

composer.gotoScene(“start”, “fade”, 400)

Just nothing fading effect happens when new scene is openning. 

I just tested it in an app I’m building and it works as expected:

Here is my entire main.lua:

local composer = require( "composer" ) -- Hide the status bar display.setStatusBar( display.HiddenStatusBar ) -- Seed the random number generator math.randomseed( os.time() ) display.setDefault( "background", 0 ) local options = {     effect = "fade",     time = 800, } -- this will eventually go to the menu scene. composer.gotoScene( "game" , options )

Now what you describe is symptomatic of either a) not putting your display objects into the scene’s view group (i.e. sceneGroup:insert(background) or b ) you are creating your objects in scene:show() instead of scene:create().

Rob

Rob, thanx! Got some fix and it start working. So we should put any graphics to sceneGroup for working FADE?? How does it connect with each other?? In advance thanx for tolerance =)

Composer is a scene manager. If you want Composer to manage  your scene, those display objects have to be added to the scene’s “view”.

Under the hood, the view is nothing more than a display.newGroup().  When you create the scene using:

local scene = composer.newScene()

It creates a new group named “view” and makes it part of the scene. i.e.:

scene.view

If you use local functions:

local function doSomething()     local sceneGroup = scene.view     ... end

If you use object functions:

function scene:doSomethingElse()     local sceneGroup = self.view     ... end

In the Composer event functions (create, show, hide, destroy), they are all of the “object function” model. With the colon operator (:), it passes an object named self to the function. So:

for object functions:  sceneGroup = self.view = scene.view.

for local functions:  sceneGroup = scene.view (no self available)

Anything you want to fade in and out must be in scene.view regardless of how you get it there:

sceneGroup:insert( object )

scene.view:insert( object ) – does the same thing as above.

I’m not sure what you mean by “How does it connect with each other??”

Rob

Rob

Just right that u wrote. I meant how is it connected(or linked)? Scene and Fade. I understood, thanx!

I just tested it in an app I’m building and it works as expected:

Here is my entire main.lua:

local composer = require( "composer" ) -- Hide the status bar display.setStatusBar( display.HiddenStatusBar ) -- Seed the random number generator math.randomseed( os.time() ) display.setDefault( "background", 0 ) local options = {     effect = "fade",     time = 800, } -- this will eventually go to the menu scene. composer.gotoScene( "game" , options )

Now what you describe is symptomatic of either a) not putting your display objects into the scene’s view group (i.e. sceneGroup:insert(background) or b ) you are creating your objects in scene:show() instead of scene:create().

Rob

Rob, thanx! Got some fix and it start working. So we should put any graphics to sceneGroup for working FADE?? How does it connect with each other?? In advance thanx for tolerance =)

Composer is a scene manager. If you want Composer to manage  your scene, those display objects have to be added to the scene’s “view”.

Under the hood, the view is nothing more than a display.newGroup().  When you create the scene using:

local scene = composer.newScene()

It creates a new group named “view” and makes it part of the scene. i.e.:

scene.view

If you use local functions:

local function doSomething()     local sceneGroup = scene.view     ... end

If you use object functions:

function scene:doSomethingElse()     local sceneGroup = self.view     ... end

In the Composer event functions (create, show, hide, destroy), they are all of the “object function” model. With the colon operator (:), it passes an object named self to the function. So:

for object functions:  sceneGroup = self.view = scene.view.

for local functions:  sceneGroup = scene.view (no self available)

Anything you want to fade in and out must be in scene.view regardless of how you get it there:

sceneGroup:insert( object )

scene.view:insert( object ) – does the same thing as above.

I’m not sure what you mean by “How does it connect with each other??”

Rob

Rob

Just right that u wrote. I meant how is it connected(or linked)? Scene and Fade. I understood, thanx!