this is my complete code Alan
– --==***************************************************************************+±- –
– Music Theory Game
– By Victor M. Barba
– Copyright 2013 – All Rights Reserved
– Version 1.0
– --==***************************************************************************+±- –
local storyboard = require( “storyboard” )
local widget = require “widget”
local scene = storyboard.newScene()
local wrongSound = audio.loadSound( “wrongSound.mp3”)
– --==******************[FUNCTIONS TO GO TO ANOTHER SCENE]**********************+±- –
local function buttonHome()
storyboard.gotoScene( “home”, “crossFade”, 1000 )
return true
end
local function buttonApple()
storyboard.gotoScene( “learn1”, “crossFade”, 1000 )
return true
end
local function buttonBulbHome()
storyboard.gotoScene( “ending”, “crossFade”, 1000 )
return true
end
local function buttonRound1()
storyboard.gotoScene( “wrong1”, “crossFade”, 1000 )
audio.play(wrongSound)
return true
end
local function buttonRound2()
storyboard.gotoScene( “wrong1”, “crossFade”, 1000 )
audio.play(wrongSound)
return true
end
local function buttonRound3()
storyboard.gotoScene( “level1Q6”, “crossFade”, 1000 )
return true
end
local function buttonRound4()
storyboard.gotoScene( “wrong1”, “crossFade”, 1000 )
audio.play(wrongSound)
return true
end
local function buttonRound5()
storyboard.gotoScene( “wrong1”, “crossFade”, 1000 )
audio.play(wrongSound)
return true
end
– --==**************************[CREATE SCENE]**********************************+±- –
function scene:createScene( event )
local group = self.view
local background = display.newImage( “backgroundLevel1Q5.png” )
buttonHome = widget.newButton{
defaultFile=“buttonHome.png”,
onRelease = buttonHome
}
buttonHome.x = 522
buttonHome.y = 655
buttonApple = widget.newButton{
defaultFile=“buttonApple.png”,
onRelease = buttonApple
}
buttonApple.x = 420
buttonApple.y = 710
buttonBulbHome = widget.newButton{
defaultFile=“buttonBulbHomeRelease.png”,
overFile=“buttonBulbHomeOver.png”,
onRelease = buttonBulbHome
}
buttonBulbHome.x = 615
buttonBulbHome.y = 685
buttonRound1 = widget.newButton{
defaultFile=“button2Counts.png”,
onRelease = buttonRound1
}
buttonRound1.x = 199
buttonRound1.y = 312
buttonRound2 = widget.newButton{
defaultFile=“button1Count.png”,
onRelease = buttonRound2
}
buttonRound2.x = 700
buttonRound2.y = 432
buttonRound3 = widget.newButton{
defaultFile=“button4Counts.png”,
onRelease = buttonRound3
}
buttonRound3.x = 800
buttonRound3.y = 300
buttonRound4 = widget.newButton{
defaultFile=“button3Counts.png”,
onRelease = buttonRound4
}
buttonRound4.x = 200
buttonRound4.y = 600
buttonRound5 = widget.newButton{
defaultFile=“buttonHalfCount.png”,
onRelease = buttonRound5
}
buttonRound5.x = 323
buttonRound5.y = 444
---------------------------------------------------------------------insert into group----
group:insert ( background )
group:insert ( buttonHome )
group:insert ( buttonApple )
group:insert ( buttonBulbHome )
group:insert ( buttonRound1 )
group:insert ( buttonRound2 )
group:insert ( buttonRound3 )
group:insert ( buttonRound4 )
group:insert ( buttonRound5 )
end
– --==***************************[ENTER SCENE]**********************************+±- –
function scene:enterScene( event )
local group = self.view
local quarterNote = display.newImage( “wholeNote.png” )
quarterNote.x = 390
quarterNote.y = 532
transition.to(quarterNote, {x=987 , y=532, time=5000})
group:insert ( quarterNote )
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
if buttonApple then
buttonApple:removeSelf()
buttonApple = nil
end
if buttonBulbHome then
buttonBulbHome:removeSelf()
buttonBulbHome = nil
end
if buttonRound1 then
buttonRound1:removeSelf()
buttonRound1 = nil
end
if buttonRound2 then
buttonRound2:removeSelf()
buttonRound2 = nil
end
if buttonRound3 then
buttonRound3:removeSelf()
buttonRound3 = nil
end
if buttonRound4 then
buttonRound4:removeSelf()
buttonRound4 = nil
end
if buttonRound5 then
buttonRound5:removeSelf()
buttonRound5 = nil
end
end
– --==*************************[EVENT LISTENER]*********************************+±- –
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene
in the enterScene I have the image display. and this scene is – level 5 or level5.lua
you can see the transition.to point A to point B without any problems and everything works fine.
so I keep playing and going to another level level 6, level 7, level 8 but when I come back to level 5 …
As soon as I see the scene, the image (quarter note) is there already in point B
and a new image quarter note start to move and going from point A to point B, and you can see two images.
I would like the scene to start normal like the first time, every time.
I hope this will help you understand my problem. And I hope that you can help me.
Thank you Alan.
Victor