espace3d
espace3d

Reputation: 23

corona composer background next scene not showing

I have a lot of difficulties with composer...it's not so easy!

My previous scene is "game" (game.lua) everything is ok When i go to my scene "recolt" with this snippet inside my game lua :

local function goTo()    
    print("gotoscene")
    composer.gotoScene( "recolt", { time = 1000, effect = "fromRight", params = params } )
end

timer.performWithDelay( 1000, goTo ) :The problem is that i see my previous scene behind my recolt scene and i can't see my background but i see my circle who's moving ??? however my sceneGroup is correct :

sceneGroup:insert(background,circle)

When i do :

sceneGroup:insert(circle,background) 

I see my background who hide my previous scene and my circle. > behavior expected

What's wrong? i would like to see my background and my circle in y "recolt" scene. Could you help me ? Thanks a lot...Below the snippet "recolt.lua".

--recolt.lua
local composer = require( "composer" )
local scene = composer.newScene()

function scene:create( event )
    local sceneGroup = self.view
    params = event.params

        local background=display.newImageRect("back02.png",display.contentWidth*.5,d        isplay.contentHeight*.5,320,480)
        background.x,background.y=display.contentWidth*.5,display.contentHeight*.5
        background.xScale,background.yScale=2,2
        background.alpha=1

        local circle = display.newCircle(120,100,100)

    sceneGroup:insert(background,circle)

    timeT=150

    local function tr4()
      transition.to(circle,{time=timeT,x=200,y=300,alpha=1,transition=easing.linear,      xScale=1,yScale=1})
    end

    local function tr3()
      transition.to(circle,{time=200,x=100,y=300,transition=easing.linear, xScale=.2      ,yScale=.5,onComplete=tr4})
    end

    local function tr2()
      transition.to(circle,{time=200,x=200,y=295,transition=easing.linear, xScale=.2      ,yScale=.2,alpha=.2,onComplete=tr3})
    end

    local function tr1()
      transition.to(circle,{time=timeT,x=300,y=300,transition=easing.linear, xScale=      .5,yScale=.5,onComplete=tr2})
    end

    timer.performWithDelay(700,tr1,-1)

end

function scene:show( event )
    local sceneGroup = self.view
    params = event.params

    if event.phase == "did" then
        --physics.start()
    end
end

function scene:hide( event )
    local sceneGroup = self.view    
    if event.phase == "will" then
        --
        -- Remove enterFrame listeners here
        --
        --physics.stop()
    end
end

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

---------------------------------------------------------------------------------
-- END OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
return scene

Upvotes: 0

Views: 166

Answers (1)

Koormo
Koormo

Reputation: 166

You need to check the docs: object:insert()

The problem is you can only add 1 object into the scene with insert() function, so you only need to change

sceneGroup:insert(background,circle)

to

sceneGroup:insert(background)
sceneGroup:insert(circle)

The order matters, the first object you create go back in the scene.

Upvotes: 1

Related Questions