Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
SceneManager transition causing app to crash — Gideros Forum

SceneManager transition causing app to crash

jmrmbzjmrmbz Member
edited July 2013 in General questions
Hello all. I'm trying to see about getting a random transition to occur between switching scenes by doing the following:

In main.lua
-- defines the scenemanager's scenes
scenemanager = SceneManager.new({
	["mainmenu"] = mainmenu,
	["gamemode"] = gamemode,
	["game"] = game,
	["contact"] = contact,
	["options"] = options,
})
 
transitions = {
	SceneManager.fade,
	SceneManager.crossFade,
	SceneManager.flip,
	SceneManager.flipWithFade,
	SceneManager.flipWithShade,
	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,
}
 
-- get a random transition from the transition table
transition = transitions[math.random(#transitions)] CAUSES CRASHING SOMETIMES
 
 
-- adds the manager to the stage
stage:addChild(scenemanager)
 
-- go to the main menu scene
scenemanager:changeScene("mainmenu", 1, transition, easing.outBack)
Sometimes when the scene changes it causes the app to crash with an error:
"classes/scenemanager.lua:327: attempt to call field 'transition' (a nil value)
stack traceback:
classes/scenemanager.lua:327: in function

However if I change the line to "transition = SceneManager.flipWithFade" it seems to run fine. Anyone has any ideas. Sorry about posting the code the way I did. I'm not sure how to post it so it looks correct.

Comments

Sign In or Register to comment.