changing scenes doesn't work

I have a little problem with corona SDK composer API. I got 3 .lua files- main.lua, character.lua and job.lua. The problem is, when I run the game, it automatically transits to character.lua and everything’s fine. Then I’m transiting to job.lua and it works as well, but when I’m trying to come back to character.lua- nothing happens (the background doesn’t change).That’s how it look like:

main.lua:

local composer = require("composer") composer.gotoScene("character")

character.lua

local composer = require( "composer" ) local scene = composer.newScene() -- ----------------------------------------------------------------------------------------------------------------- -- All code outside of the listener functions will only be executed ONCE unless "composer.removeScene()" is called. -- ----------------------------------------------------------------------------------------------------------------- -- local forward references should go here -- ------------------------------------------------------------------------------- -- "scene:create()" function scene:create( event ) local sceneGroup = self.view -- Initialize the scene here. -- Example: add display objects to "sceneGroup", add touch listeners, etc. local widget = require("widget") local bottomTabButtons ={ { width=32, height=32, defaultFile="character.png", overFile="character\_active.png", selected="true"}, { width=32, height=32, defaultFile="job.png", overFile="job\_active.png", onPress=function() composer.gotoScene( "job" )end}, } local bottomBar = widget.newTabBar{ top = display.contentHeight-40, buttons = bottomTabButtons } end -- "scene:show()" function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Called when the scene is still off screen (but is about to come on screen). elseif ( phase == "did" ) then -- Called when the scene is now on screen. -- Insert code here to make the scene come alive. -- Example: start timers, begin animation, play audio, etc. end end -- "scene:hide()" function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Called when the scene is on screen (but is about to go off screen). -- Insert code here to "pause" the scene. -- Example: stop timers, stop animation, stop audio, etc. elseif ( phase == "did" ) then -- Called immediately after scene goes off screen. end end -- "scene:destroy()" function scene:destroy( event ) local sceneGroup = self.view -- Called prior to the removal of scene's view ("sceneGroup"). -- Insert code here to clean up the scene. -- Example: remove display objects, save state, etc. end -- ------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ------------------------------------------------------------------------------- return scene

job.lua:

local composer = require( "composer" ) local widget = require("widget") local scene = composer.newScene() -- ----------------------------------------------------------------------------------------------------------------- -- All code outside of the listener functions will only be executed ONCE unless "composer.removeScene()" is called. -- ----------------------------------------------------------------------------------------------------------------- -- local forward references should go here -- ------------------------------------------------------------------------------- -- "scene:create()" function scene:create( event ) local sceneGroup = self.view -- Initialize the scene here. -- Example: add display objects to "sceneGroup", add touch listeners, etc. local background = display.newImage("background.png") background.x=display.contentCenterX background.y=display.contentCenterY background.height=display.contentHeight background.width=display.contentWidth local function gotoCharacter(event) composer.gotoScene("character") print('asd') end local bottomTabButtons ={ { width=32, height=32, defaultFile="character.png", overFile="character\_active.png", onPress=function() composer.gotoScene( "character" ) end}, { width=32, height=32, defaultFile="job.png", overFile="job\_active.png", selected="true"}, } local bottomBar = widget.newTabBar{ top = display.contentHeight-40, buttons = bottomTabButtons } end -- "scene:show()" function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Called when the scene is still off screen (but is about to come on screen). elseif ( phase == "did" ) then -- Called when the scene is now on screen. -- Insert code here to make the scene come alive. -- Example: start timers, begin animation, play audio, etc. end end -- "scene:hide()" function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Called when the scene is on screen (but is about to go off screen). -- Insert code here to "pause" the scene. -- Example: stop timers, stop animation, stop audio, etc. elseif ( phase == "did" ) then -- Called immediately after scene goes off screen. end end -- "scene:destroy()" function scene:destroy( event ) local sceneGroup = self.view -- Called prior to the removal of scene's view ("sceneGroup"). -- Insert code here to clean up the scene. -- Example: remove display objects, save state, etc. end -- ------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ------------------------------------------------------------------------------- return scene

Thanks in advance!

You don’t ever add your objects to the scene’s “view” group. Composer scenes use a display.newGroup() that is known as:

scene.view

As a convenience in scene:create() and scene:show() etc. we reference it via self.view (since the scene is passed into the event handlers as self) and we make a local variable called sceneGroup point to the view. At the top of the event functions you should see a line like:

local sceneGroup = self.view

You have to insert any display objects (and widgets) that you want the scene to manage into that group, or they are not part of the scene.  Simply do:

sceneGroup:insert( background )

and repeat for anything else  you create. If you need to insert things into the group outside of scene;create() or scene:show() then you would simply do:

scene.view:insert( object )

Rob

You don’t ever add your objects to the scene’s “view” group. Composer scenes use a display.newGroup() that is known as:

scene.view

As a convenience in scene:create() and scene:show() etc. we reference it via self.view (since the scene is passed into the event handlers as self) and we make a local variable called sceneGroup point to the view. At the top of the event functions you should see a line like:

local sceneGroup = self.view

You have to insert any display objects (and widgets) that you want the scene to manage into that group, or they are not part of the scene.  Simply do:

sceneGroup:insert( background )

and repeat for anything else  you create. If you need to insert things into the group outside of scene;create() or scene:show() then you would simply do:

scene.view:insert( object )

Rob