Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Passing variables with scene manager — Gideros Forum

Passing variables with scene manager

twisttaptwisttap Member
edited August 2012 in General questions
is it possible to pass some variables with scenemanager for init() state of a class ?
I have 4 different scenes I created a class and I want to pass some basic variables to shape the scene but also want to use
scenemanager ?

anyone ?


  • Not sure, but I think @ndos that a modification that would allow passing variables to other scenes

  • in scenemanager.lua changescene function there is a options parameter but I couldnt figure how to do it.
  • ar2rsawseenar2rsawseen Maintainer
    edited August 2012 Accepted Answer
    In @ndoss scenemanager it should be like this:
    sceneManager:changeScene(nextScene(), 1, SceneManager.flipWithShade,
     easing.inOutQuadratic, {userData = "your value to pass"})
  • @ar2rsawseen And how do I retrive that userData on new scene ?
    self.userData or like does not work :/
  • ScouserScouser Guru
    Accepted Answer
    @twisttap: Whatever data you set as userData will be passed to your scene init function.
    sceneManager:changeScene(nextScene(), 1, SceneManager.flipWithShade, 
         easing.inOutQuadratic, {userData = "Scene Title Text"})
    Passes the string "Scene Title Text" to your scene
    function myScene:init(string)
    	self.theTitle = string
    Or even more usable
    sceneManager:changeScene(nextScene(), 1, SceneManager.flipWithShade, 
         easing.inOutQuadratic, {userData = {x=100,y=100,col=0xff00ff,alpha=0.5}})
    Is used like this
    function myScene:init(params)
    	if params ~= nil then
    		self.xPos = params.x
    		self.yPos = params.y
    		self.Colour = params.col
    		self.Alpha = params.alpha

    Likes: twisttap, MoKaLux

    +1 -1 (+2 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited June 2020
    please note this does not work:
    scenemanager:changeScene("intro", 2, {userData = "hello"})
    you have to pass nil if you don't want to specify flip and/or easing
    scenemanager:changeScene("intro", 2, nil, nil, {userData = "hello"})
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • This is a magical and fun website
Sign In or Register to comment.