Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Need help with scene manager — Gideros Forum

Need help with scene manager

xGuiltxGuilt Member
edited May 2013 in General questions
So yeah, i'm new to Gideros and recently found about the sceneManager class and i've been lurking around google looking for tutorials about it and found some but unfortunately i've encountered a problem and can't seem to find a solution.

I've already included the scenemanager.lua into my project and in my main.lua i've placed this code:

----------------
local sceneManager = sceneManager.new({
["splash"] = splash,
["title"] = title,
})

stage:addChild(sceneManager)
----------------

and i've been getting an error "attempt to index global 'SceneManager' (a nil value)"
i've read that this error means that the "sceneManager" doesn't exist that's why it's a nil value and could be fixed by having the scenemanager.lua but it still appears. can anyone help me? thank you in advance

Comments

  • fxonefxone Member
    edited May 2013
    @xGuilt welcome!
    local sceneManager = SceneManager.new({
    ["splash"] = splash,
    ["title"] = title,
    })
     
    stage:addChild(sceneManager)
    ;)
    ps.
    http://www.giderosmobile.com/DevCenter/index.php/Forum_FAQ#How_can_I_highlight_my_Lua_code_in_the_forum_post.3F

    Likes: xGuilt

    +1 -1 (+1 / -0 )Share on Facebook
  • xGuiltxGuilt Member
    oh so it's SceneManager not sceneManager. I've changed it and even tried to copy the code in your post but i still get the same error. Did i do something wrong that the class can't be seen?
  • fxonefxone Member
    edited May 2013
    oh sorry @xGuilt , it should be global in this case, not local variable
    sceneManager = SceneManager.new({
    ["splash"] = splash,
    ["title"] = title,
    })
     
    stage:addChild(sceneManager)

    Likes: xGuilt

    +1 -1 (+1 / -0 )Share on Facebook
  • xGuiltxGuilt Member
    Thanks! it worked and i've overlooked a silly mistake, i forgot to set the code dependencies -_-

    unfortunately i have met another problem. (sorry if i'm asking too much)
    	if self.scene1 == nil then
    		self.scene1 = self.scenes[scene].new(options and options.userData)
    		self:addChild(self.scene1)
    		dispatchEvent(self, "transitionBegin")
    		dispatchEvent(self.scene1, "enterBegin")
    		dispatchEvent(self, "transitionEnd")
    		dispatchEvent(self.scene1, "enterEnd")
    		return
    	end
    it seems that now i'm getting an error in the scenemanager.lua file "attempt to index field '?' (a nil value)" i'm using the exact file from the scene manager project. should i change the scene1,etc,etc?
  • I'm not sure if this is valid but the comma after title can cause problems as sceneManager may think that your table of scenes has one more entry that it actually does. Try deleting that comma and see if it fixes the problem.

    Likes: xGuilt

    +1 -1 (+1 / -0 )Share on Facebook
  • zvardinzvardin Member
    The comma shouldn't be a problem at the end. It's hard to say without seeing more of the code, but I wouldn't be surprised if your scenes should be capitalized.
    sceneManager = SceneManager.new({
    ["splash"] = Splash,
    ["title"] = Title,
    })

    Likes: xGuilt

    +1 -1 (+1 / -0 )Share on Facebook
  • xGuiltxGuilt Member
    I'm not sure if this is valid but the comma after title can cause problems as sceneManager may think that your table of scenes has one more entry that it actually does. Try deleting that comma and see if it fixes the problem.
    still the same after deleting the coma.
    The comma shouldn't be a problem at the end. It's hard to say without seeing more of the code, but I wouldn't be surprised if your scenes should be capitalized.
    sceneManager = SceneManager.new({
    ["splash"] = Splash,
    ["title"] = Title,
    })
    Well the only codes left to see is the:
    stage:addChild(sceneManager)
     
    sceneManager:changeScene("splash", 1, SceneManager.fade, easing.linear)
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2013
    @xGuilt check out the Game Template: https://github.com/ar2rsawseen/GameTemplate

    About this code
    sceneManager = SceneManager.new({
    ["splash"] = Splash,
    ["title"] = Title,
    })
    1) You should have scenes with the same names as you provided (Splash, Title, etc)
    2) Scenes must inherit at least from Sprite
    3) this code should be in the main.lua because it will be executed last, when all lua files of defined scenes are already found and executed
Sign In or Register to comment.