I have 3 scenes. A, B and C.
in Scene A I have an image of a lady Bug moving from point A to point B
(using transition.to)
now, the lady bug Image is in point B, in scene A.
when I go to scene B, then scene C everything is fine.
when I come back to scene A, the lady bug is ALREADY there in point B
and a new lady bug comes out and moves, from point A to point B, now I have 2 lady bugs.
I want to know how to refresh the scene, so every time I go back to that scene, the programs runs from scratch.
Thanks for your help.
http://www.youtube.com/watch?v=CKNr7Z8ak1w&feature=youtu.be
This is the complete code.
local storyboard = require( “storyboard” )
local widget = require “widget”
local scene = storyboard.newScene()
local wrongSound = audio.loadSound( “noteDo4.mp3”)
– --==******************[FUNCTIONS TO GO TO ANOTHER SCENE]**********************+±- –
local function buttonHome()
storyboard.gotoScene( “sceneB”, “crossFade”, 1000 )
return true
end
– --==**************************[CREATE SCENE]**********************************+±- –
function scene:createScene( event )
local group = self.view
local background = display.newImage( “backgroundLevel1Q6.png” )
buttonHome = widget.newButton{
defaultFile=“buttonHome.png”,
onRelease = buttonHome
}
buttonHome.x = 522
buttonHome.y = 655
---------------------------------------------------------------------insert into group----
group:insert ( background )
group:insert ( buttonHome )
end
– --==***************************[ENTER SCENE]**********************************+±- –
function scene:enterScene( event )
local group = self.view
local ladyBug = display.newImage( “ladyBug.png” )
ladyBug.x = 100
ladyBug.y = 500
transition.to(ladyBug, {x=700 , y=500, time=5000})
group:insert ( ladyBug )
end
– --==***************************[EXIT SCENE]**********************************+±- –
function scene:exitScene( event )
local group = self.view
end
– --==**************************[DESTROY SCENE]*********************************+±- –
function scene:destroyScene( event )
local group = self.view
if buttonHome then
buttonHome:removeSelf()
buttonHome = nil
end
end
– --==*************************[EVENT LISTENER]*********************************+±- –
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene
Thanks
Victor