Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
SceneManager only one button Working — Gideros Forum

SceneManager only one button Working

rcorreiaptptrcorreiaptpt Member
edited February 2014 in General questions
Hello all i´m having trouble with sceneManager here is my code:
main.lua:
sceneManager = SceneManager.new({
["start"] = start,
["level"] = level,
["credits"] = credits,
})
stage:addChild(sceneManager)
sceneManager:changeScene("start",1,SceneManager.moveFromRight)

---------------------------------------------------------------------------------------------------
start.lua:
start = gideros.class(Sprite)
function start:init()
local mainscreen = Bitmap.new(Texture.new("images/start_screen.png"))
stage:addChild(mainscreen)
local startbt = Bitmap.new(Texture.new("images/start_bt.png"))
local buttonS = Button.new(startbt,startbt)
startbt:setPosition(50,220)
stage:addChild(startbt)
buttonS:addEventListener("click",
function()
sceneManager:changeScene("level",1,SceneManager.moveFromRight)
end
)
local creditbt =Bitmap.new(Texture.new("images/credits_bt.png"))
local buttonC = Button.new(creditbt,creditbt)
stage:addChild(buttonC)
creditbt:setPosition(200,220)
buttonC:addEventListener("click",
function()
sceneManager:changeScene("credits",1,SceneManager.moveFromRight)
end
)
end

----------------------------------------------------------------------------------
The problem is only one button is working the buttonC, the ButtonS is not working i click and nothings happens :( thanks in advance.

Comments

  • yubaroyubaro Member
    edited February 2014 Accepted Answer
    Hi!

    Try that, changing stage:addChild(startbt) to stage:addChild(buttonS)

    I hope run you!

    Likes: rcorreiaptpt

    +1 -1 (+1 / -0 )Share on Facebook
  • Thanks a lottttt :) :) really thank you :D it´s working
  • @rcorreiaptpt yes as @yubaro noticed, you were adding Bitmap image and not the Button object.
    But even more, you should add everything to the scene, like:
    self:addChild(buttonS)
    and not to the stage, thus the content would actually change upon changing the scene, or else what is added to the stage will be always visible, no matter what scene you are on ;)
  • @ar2rsawseen is absolutely right! :)>-
Sign In or Register to comment.