How do I : Sprite button states [SOLVED]

0 favourites
  • 8 posts
From the Asset Store
Casual UI Button #3 is a customizable, ready to use desktop and mobile-friendly game UI Asset.
  • Sprite button states:

    Im making a WORD SEARCH GAME

    I have a sprite that has 2 FRAMES, animation speed 0 (Frame 0 is on, Frame 1 is Off)

    As I schedule for Sprite touching the button switch to off, and I touch the button again to switch on?

    This sis te CAPX

    https://dl.dropboxusercontent.com/u/19024090/Soup.capx

    Greetings and Thanks

  • Create a global variable that tracks the on/off.

    Create an event that changes the variable whenever the button is hit. So for example:

    On touch myButton

    If myVariable = 0

    Set myVariable = 1

    else

    Set myVariable = 0

    Then for the state of the button, set the frame to match your variable.

    myButton animationFrame = myVariable

  • Just change your "activo" variable type to BOOLEAN

    Now when you touch your sprite , the boolean "activo" switch between TRUE & FALSE.

    If Activo is true : set frame 1

    If Activo is false : set frame 0

  • Just change your "activo" variable type to BOOLEAN

    Now when you touch your sprite , the boolean "activo" switch between TRUE & FALSE.

    If Activo is true : set frame 1

    If Activo is false : set frame 0

    GREAT works perfect!

    Thanks friend.

    Greetings from CHILE!

  • You don't need a separate variable at all. You already have two values that hold the state: the frame numbers themselves. Also, you method is inefficient as the frames are set every tick. This method only changes the frame 'on touched'. (Doesn't make much difference yet, but as things get bigger, it's better practice to reduce overhead).

  • blackhornet're right, what I showed has a condition that is not necessary. it is preferable to use the condition of the frame directly.

  • Thanks blackhornet you CAPX run perfect.

    There are things that even I can not understand as "ELSES" the "FOR", "FOR EACH" and "booleans"

    I need some explanation "FOR DUMMIES".

    You are very efficient!!!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Or this:

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