Hi,
I’m wondering if there’s anyway that could allow me to choose randomly between .lua files when gotoScene,
is there any way to do that ?
Hi,
I’m wondering if there’s anyway that could allow me to choose randomly between .lua files when gotoScene,
is there any way to do that ?
It should be relatively easy to code this up on your own.
Beginner style:
local function randomSceneCal() local sceneRnd = math.random(5) if sceneRnd == 1 then storyboard.gotoScene("scene1") elseif sceneRnd == 2 then storyboard.gotoScene("scene2") end end
you could easily stick all of your file names into a table and iterate randomly through it to get a random name.
sceneNames = { "scene1", "scene2", "scene3", "scene4", "scene5", } local function callRndScene() local sceneRnd = math.random(5) storyboard.gotoScene(sceneNames[sceneRnd])
or you could just include all level info inside of one scene file, and just randomize the call of functions from within. I don’t have an easy explanation of this one, but the forums have lots of posts describing the behavior.
^^
well, that’s it, the first code you wrote is the one, thanks a lot man.
It should be relatively easy to code this up on your own.
Beginner style:
local function randomSceneCal() local sceneRnd = math.random(5) if sceneRnd == 1 then storyboard.gotoScene("scene1") elseif sceneRnd == 2 then storyboard.gotoScene("scene2") end end
you could easily stick all of your file names into a table and iterate randomly through it to get a random name.
sceneNames = { "scene1", "scene2", "scene3", "scene4", "scene5", } local function callRndScene() local sceneRnd = math.random(5) storyboard.gotoScene(sceneNames[sceneRnd])
or you could just include all level info inside of one scene file, and just randomize the call of functions from within. I don’t have an easy explanation of this one, but the forums have lots of posts describing the behavior.
^^
well, that’s it, the first code you wrote is the one, thanks a lot man.