I use SceneManager to manage my scenes.
Is there a way to access a scene initiated by SceneManager from outside?
Here is what I tried.
GameScene.lua:
GameScene = Core.class(Sprite)
function GameScene:init()
self.hello = TextField.new(nil, "hello")
self.hello:setPosition(50,50)
self:addChild(self.hello)
end
main.lua:
sceneManager = SceneManager.new({
["gameScene"] = GameScene
})
stage:addChild(sceneManager)
sceneManager:changeScene("gameScene", SceneManager.fade, 0, easing.outBack)
sceneManager.scenes["gameScene"].hello:setText("changed")
Error message: main.lua:12: attempt to index field 'hello' (a nil value)
Comments
It works. I was a bit confused about the if-query, because in this simple scenario it is clear that the scene instance exists. But apparently what matters is how you call the scene.
However, thanks again!!
I just realized to use scenemanager this way doesn't make any sense, or?
I planned to have a "main scene" (gameScene) where the most important variables are stored and that scene is always active.
But I should rather just store those main variables in the init file
Passing values between scenes:
http://giderosmobile.com/forum/discussion/1474/passing-variables-with-scene-manager/p1
Likes: Holonist