I've been trying to use the SceneManager to fade between two scenes. Unfortunately it's not working and I'm sure I'm missing something obvious.
---main.lua---
application:setOrientation(Application.LANDSCAPE_LEFT)
sceneManager = SceneManager.new({
["splash"] = splash,
["game"] = game
})
stage:addChild(sceneManager)
sceneManager:changeScene("splash") |
---splash.lua---
splash = gideros.class(Sprite)
function splash:init()
stage:addChild(Bitmap.new(Texture.new("images/logoSplash.png")))
local timer = Timer.new(2000, 1)
timer:addEventListener(Event.TIMER_COMPLETE,
function()
sceneManager:changeScene("game", 1, SceneManager.fade, easing.linear)
end
)
timer:start()
end |
---game.lua---
game = gideros.class(Sprite)
function game:init()
stage:addChild(Bitmap.new(Texture.new("images/gameBackground.png")))
end |
Comments
Well usually changing scenes is something like this:
sceneManager:changeScene("splash", 1, SceneManager.flipWithFade, easing.outBack)
And you don't add elements to stage anymore, add them to scenes themselves
self:addChild(someSprite)
You can check out an example and description here:
http://appcodingeasy.com/Gideros-Mobile/Manage-Scenes-in-Gideros-Mobile
The stage:addChild(someSprite) was the problem that I didn't catch. Changing it to self worked.
Thanks
Likes: MoKaLux