Quick Links: Gideros Home | Download Gideros | Developer Guide
Passing variables with scene manager - Gideros Forums
Passing variables with scene manager
  • Hi,
    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

    http://www.giderosmobile.com/forum/discussion/comment/4856
  • in scenemanager.lua changescene function there is a options parameter but I couldnt figure how to do it.
  • ar2rsawseenar2rsawseen +1 -1
    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 :/
  • Scouser +1 -1 (+1 / -0 )
    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
    end
    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
    end
    end

    Loves: twisttap

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with Google Sign In with OpenID

In this Discussion

Top Posters