How do I handle button states

0 favourites
  • 3 posts
From the Asset Store
J-BoB Game Button Sound Pack comes with 300 high-quality sound effects
  • i have several buttons and i want the buttons to have several different states without having to' write' same code over again

    my buttons are sprites btw

    states are:

    *enabled(btn sprite frame 1)/ disabled(sprite to frame 0)

    *pressed/clicked(button sprite switches to to frame 2 for a few miliseconds)

    is there any way to do this without having to 'write a bunch of code for each button?

    i would like to be able to set btn1.disabled , and the software should automatically set the sprite to frame 0since im gonna have many buttons , i want to avoid writing this for every single button,is there a button plugin, that can help me out?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could put all your sprites in a family then you only have to code the events of what to do on touched

  • Use Families. Add all your buttons to a Family. Add Family instance variables Enabled, Pressed/Clicked, etc. Also, add a 'callback' variable.

    Use callbacks to automatically go to a section of code (call a certain function) when a particular is button is clicked.

    Example:

    On Touched "Button"

    -- Call Function (Button.callback)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)