Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
attempt to index global 'sceneManager' (a nil value) problem — Gideros Forum

attempt to index global 'sceneManager' (a nil value) problem

loves_oiloves_oi Member
edited September 2012 in General questions
I'm taking this error:
sources/screens/optionScreen.lua:193: attempt to index global 'sceneManager' (a nil value)
stack traceback:
	sources/screens/optionScreen.lua:193: in function <sources/screens/optionScreen.lua:184>
this the line which causes error:
sceneManager:changeScene("results", 1, SceneManager.flipWithFade, easing.outBack,mydata)
I thought that code dependency may cause this error. But it is seen no problem in dependency , i think. I added the photo of dependencies.
i checked the sceneManager.lua. It exists in my project in sources->classes->sceneManager.lua
What may cause the error ? Any idea?
Thanks in advance.

Likes: CodeVanya

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • Do you have a scene defined like "results" in your scenecontroller.lua (Scenemaneger).
    (Also corresponding lua file to "results" scene)
  • loves_oiloves_oi Member
    edited September 2012
    yes , defined result scene, here: (in main.lua)
    sceneManager = SceneManager.new({
    --	["logoScreen"] = logoScreen,
    --	["menuScreen"] = menuScreen,
    --	["gameScreen"] = gameScreen,
    --	["levelEndScreen"] = levelEndScreen,
    --	["nextLevelScreen"] = nextLevelScreen,
    	["optionScreen"] = optionScreen,
    	["results"] = results,
    	["switch"] = switch,
    	["sld"] = sld
    })
     
    local scenes = {"optionScreen" , "results" , "switch" , "sld" }
    it can change to optionScreen page. But it cannot change from optionScreen page to results page
  • do you have results.lua file in your project and inside it did you define results class? If yes can you please post here for further investigation:D
  • loves_oiloves_oi Member
    edited September 2012
    i found the reason of the error. I was unintentionally creating the instance of sceneManager class two times at main.lua. Namely:
     
    sceneManager = SceneManager.new({
     
    	["scene1"] = scene1
    })
     
    local scenes = {"scene1"  }
     
    .........
     
    sceneManager = SceneManager.new({
    	["optionScreen"] = optionScreen,
    	["results"] = results,
    	["switch"] = switch,
    	["sld"] = sld
    })
     
    local scenes = {"optionScreen" , "results" , "switch" , "sld" }
    When i delete the first one , it works perfectly.

    But now i have encountered a new problem. I'm trying to integrate keyboard code(i did a login page using this) with the sceneManager code.

    If i explain it more clearly , i have two different projects; one for login page and the other one for checkbox page. It works perfectly.

    Now i'm trying to integrate them. After login page , the user is redirected to the checkbox page. But after integrating them , the size of checkboxes page and the other pages which follows checkbox page increased. I added the photos which shows run process after integrating both code.

    Actually , before integrating them , checkboxes page and the pages which follows it looked smaller . After integrating with keyboard , it looks so big and the screen is not enough.

    How can i make it smaller? Why does the size of them increase?

    Here is my main:
     
    	local keyboard = KeyBoard.new("en_GB")
    	keyboard:Create()
     
    	local label1 = TextField.new(nil,"Username : ")
    	label1:setPosition(40, 45)
    	label1:setTextColor(0xFF1300)
    	stage:addChild(label1)
     
    	local label2 = TextField.new(nil,"Password")
    	label2:setPosition(40, 100)
    	label2:setTextColor(0xFF1300)
    	stage:addChild(label2)
     
    	local inputbox = InputBox.new(150,20,150,40)
    	inputbox:setText("")
    	inputbox:SetKeyBoard(keyboard)
    	inputbox:setBoxColors(0xefefef,0xff2222,0,1)
    	inputbox:setActiveBoxColors(0xff5555,0xff2222,0,1)
    	stage:addChild(inputbox)
     
    	local inputbox2 = InputBox.new(150,80,150,40)
    	inputbox2:setText("")
    	inputbox2:SetKeyBoard(keyboard)
    	inputbox2:setBoxColors(0xefefef,0xff2222,0,1)
    	inputbox2:setActiveBoxColors(0xff5555,0xff2222,0,1)
    	stage:addChild(inputbox2)
     
    	stage:addChild(keyboard)
     
    	local a = TextField.new(nil,"Loading")
     
    	local upp = Bitmap.new(Texture.new("button.png"))
    	local down = Bitmap.new(Texture.new("application lifecycle.png"))
     
    	-- create the button
    	local button = Button.new(upp, down)
    	button:setPosition(200, 120)
    	stage:addChild(button)
     
    	nameTaken = ""
    	local click = 0
     
    button:addEventListener("click",
    	function()
    		if inputbox:getText() == "test" then
    			inputbox:setText("done")
    		else
    			nameTaken = inputbox:getText()
    			passwordTaken = inputbox2:getText()
    			print (nameTaken)
    			print (passwordTaken)
     
    			print (nameTaken .. "---")
     
    			local loader = UrlLoader.new("<a href="http://localhost/checklogin.php?myusername=&quot" rel="nofollow">http://localhost/checklogin.php?myusername=&quot</a>; .. nameTaken .. "&mypassword=" .. passwordTaken)
     
    			local function onComplete(event)
     
    				local myString=event.data      -- We got the string here.
    				print ("myString = " .. myString)
    				local length = string.len(myString)
    				local i = 1
     
    				local echoString = ""
    				while (i < length+1) do
     
    					echoString = echoString .. string.sub(myString,i,i)
    					i = i+1;
    				end
     
    				a:setText(echoString)
    				a:setPosition(10, 185)
    				a:setTextColor(0x007B25)
    				stage:addChild(a)
     
    				print (echoString)
     
    				loader:removeEventListener(Event.COMPLETE, onComplete)
     
    				controlName = string.sub(echoString,1,7)
     
    				if(controlName == 'Welcome') then
    					------------------------
    					sceneManager = SceneManager.new({
    	["optionScreen"] = optionScreen,
    	["results"] = results,
    	["switch"] = switch,
    	["sld"] = sld
    })
     
    local scenes = {"optionScreen" , "results" , "switch" , "sld" }
     
    sceneManager:addEventListener("transitionBegin", function() print("manager - transition begin") end)
    sceneManager:addEventListener("transitionEnd", function() print("manager - transition end") end)
     
    --add manager to stage
     
    stage:addChild(sceneManager)
     
     transitions = {
    	SceneManager.moveFromLeft,
    	SceneManager.moveFromRight,
    	SceneManager.moveFromBottom,
    	SceneManager.moveFromTop,
    	SceneManager.moveFromLeftWithFade,
    	SceneManager.moveFromRightWithFade,
    	SceneManager.moveFromBottomWithFade,
    	SceneManager.moveFromTopWithFade,
    	SceneManager.overFromLeft,
    	SceneManager.overFromRight,
    	SceneManager.overFromBottom,
    	SceneManager.overFromTop,
    	SceneManager.overFromLeftWithFade,
    	SceneManager.overFromRightWithFade,
    	SceneManager.overFromBottomWithFade,
    	SceneManager.overFromTopWithFade,
    	SceneManager.fade,
    	SceneManager.crossFade,
    	SceneManager.flip,
    	SceneManager.flipWithFade,
    	SceneManager.flipWithShade,
    }
     
     
    --start start scene
    sceneManager:changeScene("optionScreen", 1, SceneManager.flipWithFade, easing.outBack)
     
     
    				end
    			end
     
    			local function onError()
    				print("error")
    			end
     
    			local function onProgress(event)
    				print("progress: " .. event.bytesLoaded .. " of " .. event.bytesTotal)
    			end
    			loader:addEventListener(Event.COMPLETE, onComplete)
    			loader:addEventListener(Event.ERROR, onError)
    			loader:addEventListener(Event.PROGRESS, onProgress)
    		end
     
    	end) --end of function which exist in button:addEventListener
    after1.png
    325 x 485 - 147K
    after2.png
    329 x 494 - 147K
    checkbox before integration.png
    335 x 501 - 171K
    checkbox before integration2.png
    332 x 498 - 117K
  • loves_oiloves_oi Member
    edited September 2012
    Everything in every page is still bigger than normal size. I can't find why..
    Here is another example of the problem. (I can't see any difference between their codes:S ) How to to fix it?

    Any help will be appreciated..
    mycode and original code.png
    701 x 649 - 110K
Sign In or Register to comment.