Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Problem With Scene Manager — Gideros Forum

Problem With Scene Manager

ljp1203ljp1203 Member
edited October 2012 in General questions
Hi all!

I'm having a problem with the Gideros Scene Manager. Whenever I try to click on my button called createBtn, I keep getting an error and it won't allow me to advance onto the next scene. And I can't seem to find the source of the problem.

Here are my files,

main.lua
sceneManager = SceneManager.new({
	["loadmain"] = loadmain,
	["login"] = login,
	["mainmenu"] = mainmenu,
	["createEvent"] = createEvent,
	["Party"] = Party,
	["Vacation"] = Vacation,
	["Other"] = Other,
	["ViewEdit"] = ViewEdit,
	["Settings"] = Settings,
	["Help"] = Help,
	["FAQ"] = FAQ,
	["About"] = About,
})
 
stage:addChild(sceneManager)
 
sceneManager:changeScene("login")
mainmenu.lua
mainmenu = gideros.class(Sprite)
function mainmenu:init()
 
 
	--Background Image
	local background = Bitmap.new(Texture.new("Images/test.png"))
	stage:addChild(background)
 
	--Create Event Button	
	local createBtn = Bitmap.new(Texture.new("Images/btn1.png"))
	local createBtn_over = Bitmap.new(Texture.new("Images/btn1_over.png"))
 
	--The Actual Button and Listener
	local button1 = Button.new(createBtn, createBtn_over)
	button1:addEventListener("click",
		function()
			sceneManager:changeScene("createEvent")
		end)
 
	--Add Button To Scene
	button1:setPosition(70, 200)
	stage:addChild(button1)	
	-------------------------------------------------------------------------------
	--Create Event Button	
	local viewBtn = Bitmap.new(Texture.new("Images/btn2.png"))
	local viewBtn_over = Bitmap.new(Texture.new("Images/btn2_over.png"))
 
	--The Actual Button and Listener
	local button2 = Button.new(viewBtn, viewBtn_over)
	button1:addEventListener("click",
		function()
			sceneManager:changeScene("ViewEdit")
		end)
 
	--Add Button To Scene
	button2:setPosition(70, 450)
	stage:addChild(button2)
	-------------------------------------------------------------------------------
	--Create Event Button	
	local settingsBtn = Bitmap.new(Texture.new("Images/btn3.png"))
	local settingsBtn_over = Bitmap.new(Texture.new("Images/btn3_over.png"))
 
	--The Actual Button and Listener
	local button3 = Button.new(settingsBtn, settingsBtn_over)
	button1:addEventListener("click",
		function()
			sceneManager:changeScene("Settings")
		end)
 
	--Add Button To Scene
	button3:setPosition(70, 700)
	stage:addChild(button3)
	-------------------------------------------------------------------------------
 
 
end
createEvent.lua
mainmenu = gideros.class(Sprite)
function mainmenu:init()
 
 
	--Background Image
	local background = Bitmap.new(Texture.new("Images/test.png"))
	stage:addChild(background)
        --This is just a test image.
 
 
end
Here is the error I keep getting:

scenemanager.lua:264: attempt to index field '?' (a nil value)
stack traceback:
scenemanager.lua:264: in function 'changeScene'
main.lua:18: in main chunk


I hope someone can help me with this because I really need this to work, or well then my app is useless :)

Thanks in Advance!
-Landon
JLS
Lead Coder and Designer

Comments

  • Well there are other parameters you need to pass as:
    --Arguments:
    --start - provided key to reference scene
    --1 - duration of transition in seconds
    --SceneManager.flipWithFade - scene transition
    --easing.outBack - easing
    sceneManager:changeScene("start", 1, SceneManager.flipWithFade, easing.outBack)
    I think easing is the only thing that is optional
  • That still didn't work, I'm still getting the same error.
    JLS
    Lead Coder and Designer
  • petecpetec Member
    Accepted Answer
    Both your main menu.lua and createEvent.lua seem to be setting up the same class main menu and both define the function mainmenu:init(), which will cause confusion. I think that createEvent.lua should start createEvent = gideros.class(Sprite) so that scene manager can find it.
    I also notticed that you are adding the backgrounds to the stage. If you want them just to belong to the scene they should be added to self rather than stage.
    Good luck!
  • ljp1203ljp1203 Member
    edited October 2012
    Hi @petec!

    I'm having a issue with the Gideros Scene Manager.

    Everytime I click the button that has the listener for changing scenes, it doesn't use the transition that I put down, it just transitions regulary.

    Here are my files:

    main.lua
    sceneManager = SceneManager.new({
    	["loadmain"] = loadmain,
    	["login"] = login,
    	["mainmenu"] = mainmenu,
    	["createEvent"] = createEvent,
    	["Party"] = Party,
    	["Vacation"] = Vacation,
    	["Other"] = Other,
    	["ViewEdit"] = ViewEdit,
    	["Settings"] = Settings,
    	["Help"] = Help,
    	["FAQ"] = FAQ,
    	["About"] = About,
    })
     
    stage:addChild(sceneManager)
     
    sceneManager:changeScene("mainmenu")
    mainmenu.lua
    mainmenu = gideros.class(Sprite)
    function mainmenu:init()
     
     
    	--Background Image
    	local background = Bitmap.new(Texture.new("Images/test.png"))
    	stage:addChild(background)
     
    	--Create Event Button	
    	local createBtn = Bitmap.new(Texture.new("Images/btn1.png"))
    	local createBtn_over = Bitmap.new(Texture.new("Images/btn1_over.png"))
     
    	--The Actual Button and Listener
    	local button1 = Button.new(createBtn, createBtn_over)
    	button1:addEventListener("click",
    		function()
    			sceneManager:changeScene("createEvent", 1, SceneManager.flipWithFade)
    		end)
     
    	--Add Button To Scene
    	button1:setPosition(70, 200)
    	stage:addChild(button1)	
    	-------------------------------------------------------------------------------
    	--Create Event Button	
    	local viewBtn = Bitmap.new(Texture.new("Images/btn2.png"))
    	local viewBtn_over = Bitmap.new(Texture.new("Images/btn2_over.png"))
     
    	--The Actual Button and Listener
    	local button2 = Button.new(viewBtn, viewBtn_over)
    	button1:addEventListener("click",
    		function()
    			sceneManager:changeScene("ViewEdit")
    		end)
     
    	--Add Button To Scene
    	button2:setPosition(70, 450)
    	stage:addChild(button2)
    	-------------------------------------------------------------------------------
    	--Create Event Button	
    	local settingsBtn = Bitmap.new(Texture.new("Images/btn3.png"))
    	local settingsBtn_over = Bitmap.new(Texture.new("Images/btn3_over.png"))
     
    	--The Actual Button and Listener
    	local button3 = Button.new(settingsBtn, settingsBtn_over)
    	button1:addEventListener("click",
    		function()
    			sceneManager:changeScene("Settings")
    		end)
     
    	--Add Button To Scene
    	button3:setPosition(70, 700)
    	stage:addChild(button3)
    	-------------------------------------------------------------------------------
     
     
    end
    createEvent.lua
    createEvent = gideros.class(Sprite)
    function createEvent:init()
     
     
    	--Background Image
    	local background = Bitmap.new(Texture.new("Images/test.png"))
    	stage:addChild(background)
     
     
    end
    I really need help with this, or my app won't work

    Thanks in Advance!
    -Landon
    JLS
    Lead Coder and Designer
Sign In or Register to comment.