When I press play button or exit button more than 1 time and don’t wait until transition finishes I am getting black screen… Any ideas to fix that?
And if I wait until transition finishes and only then press the button everything is good, until I do it for about 10 times and then black screen comes.
Code:
local playButton = display.newSprite(sceneGroup,playSheet,sq)
playButton:scale( 1.5, 1.5 )
playButton.x = right - 70
playButton.y = bottom - 40
local function Play(event)
if(event.phase == "began") then
if playerLevel == 0 then
local options =
{
effect = "crossFade",
time = 1000
}
storyL = 1
timer.performWithDelay(1500, function() playButton:addEventListener("touch",Play) end)
composer.gotoScene("scenes.SpaceMap",options)
composer.gotoScene("scenes.story",options)
else
local options =
{
effect = "fromRight",
time = 1000
}
playButton:removeEventListener("touch", Play)
timer.performWithDelay(1500, function() playButton:addEventListener("touch",Play) end)
composer.gotoScene("scenes.SpaceMap",options)
end
end
end
playButton:addEventListener("touch", Play)
-- Other scene
local backButton = display.newSprite(sceneGroup,playSheet,sq)
backButton:setSequence("back")
backButton.x = left + 40
backButton.y = top + 40
backButton:scale(0.7,0.7)
local function back()
local options =
{
effect = "fromLeft",
time = 1000
}
backButton:removeEventListener("touch",back)
timer.performWithDelay(1500, function() backButton:addEventListener("touch",back) end)
composer.gotoScene("scenes.lobby", options)
end
backButton:addEventListener("touch",back)
Video: