I’m using composer to transition between scenes, and I’m retrofitting it to an old project. One thing I’ve noticed is that on some transitions, display items are being deleted while they are still on screen, so they visually pop out of existence which looks awful. I’m trying to figure out if it’s a bug with composer or (more likely) something I’m doing wrong.
Here’s my abridged code:
[lua]
local composer = require “composer”
local game=require “game”
local scene = composer.newScene()
local gameInstance
function scene:show(event)
if event.phase==“will” then
gameInstance=game.start()
self.view:insert(gameInstance)
end
end
function scene:hide(event)
if event.phase==“did” then
gameInstance:removeSelf()
end
end
scene:addEventListener(“create”, scene)
scene:addEventListener(“show”, scene)
scene:addEventListener(“hide”, scene)
return scene
[/lua]
In game.lua I then call the following when I want to exit the above scene:
[lua]
composer.gotoScene(“scenes.map”,{
effect = “crossFade”,
time = 500
})
[/lua]
So the issue is that the line gameInstance:removeSelf is being called while the gameInstance display group is still visible. It’s fixable using a timer to delay the call, but based on that composer call, I would expect all items to have faded out by the time the event is called. Has anyone else had any issues with this or know what might be causing this problem?