Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to slow down the speed of the button to appear on stage. — Gideros Forum

How to slow down the speed of the button to appear on stage.

OrhunOrhun Member
edited January 2016 in Game & application design
Hi everybody,
I'm am trying to develop a simple soundboard app.
In my app splash screen i created a animated character sprite and a simple start button sprite.

My problem is, i don't know how to slow down the speed of the start button to appear on stage.
I want to set it visible after my animated character sprite appears on stage.For example 2-3 second later.
But my button sprite appearing on the stage first.
Which function code controls this.

My button code is the following."Baslat" is my button name.

local up = Bitmap.new(Texture.new("up.png"))
local down = Bitmap.new(Texture.new("down.png"))
local Baslat = Button.new(up, down)
Baslat:setPosition(100, 450)
stage:addChild(Baslat)

Help please.

Comments

  • piepie Member
    Hi @Orhun, try this
    http://docs.giderosmobile.com/reference/gideros/Timer/delayedCall
    Timer.delayedCall(1000 , function()
    local up = Bitmap.new(Texture.new("up.png"))
    local down = Bitmap.new(Texture.new("down.png"))
    local Baslat = Button.new(up, down)
    Baslat:setPosition(100, 450)
    stage:addChild(Baslat)
    end)
  • The best way to achieve this using "ADDED_TO_STAGE" event for your character sprite. When event fires then you can add your button to stage.
    characterSprite:addEventListener(Event.ADDED_TO_STAGE ,function()
          -- add your button here
    end,self)
  • Thanks for the replies.
    Mertocan, i tried your code but it didn't worked. is the following code correct?my character sprite name is "bb8".I couldn't find the error
    bb8:addEventListener(Event.ADDED_TO_STAGE ,function()
          local up = Bitmap.new(Texture.new("up.png"))
    local down = Bitmap.new(Texture.new("down.png"))
    local Baslat = Button.new(up, down)
    Baslat:setPosition(100, 450)
    stage:addChild(Baslat)
    end,self)
    By the way i am a complete newbie in programming except graphic design:)
    So my questions can be very simple.
  • Which error are you getting?

    I think you are trying to do it on stage. Therefore, your self is nil.

    Try this one. It should work.
    bb8:addEventListener(Event.ADDED_TO_STAGE ,function()
          local up = Bitmap.new(Texture.new("up.png"))
          local down = Bitmap.new(Texture.new("down.png"))
          local Baslat = Button.new(up, down)
          Baslat:setPosition(100, 450)
          stage:addChild(Baslat)
    end,bb8)
    BTW, to make it clear, you should move event function to outside of scope in order to remove event when it is completed. So,
     
    function addButtonToStage()
     
          local up = Bitmap.new(Texture.new("up.png"))
          local down = Bitmap.new(Texture.new("down.png"))
          local Baslat = Button.new(up, down)
          Baslat:setPosition(100, 450)
          stage:addChild(Baslat)
     
          bb8:removeEventListener(Event.ADDED_TO_STAGE ,addButtonToStage(),bb8)
    end
     
     
    bb8:addEventListener(Event.ADDED_TO_STAGE ,addButtonToStage(),bb8)

    is better implementation.
Sign In or Register to comment.