How do I create a functioning check box?

  • Hi all - So I am trying to create a check box. Here's what I have so far. An object that is the check box and an object that is a check mark. I want to click on the box and have a check mark spawn so that it gives off the appearance that you "checked" the box. I know how to make it so that when you click on the box the check mark spawns at the origin point. My problem is unchecking the box and then rechecking it and so on and so forth. How do I make it so I can click on the box, have the check mark appear, click on the box again, have the check mark disappear, and then be able to do that back and forth, back and forth. Thanks!

  • Here's a start

  • codah

    Thanks! One question... What allows for the object to toggle back and forth between animation frames like that?

  • The expression 1 - Sprite1.AnimationFrame

    If the animation frame is currently 0, then 1 - 0 = 1 and so the frame will change to 1 (checked)

    If the animation frame is currently 1, then 1 - 1 = 0 and so the frame will change to 0 (unchecked)

    As you saw I made the 2 states as frames in the one sprite rather than 2 sprites, and turned animationspeed to 0 in properties, so they didn't animate between the frames when we didn't want them to.

    You can add an instance variable to track state (checked/unchecked) or just continue to use 'Sprite1.AnimationFrame'. If the latter, I suggest you create 2 constant global variables

    UNCHECKED = 0

    CHECKED = 1

    and use those instead of 0 and 1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you very much!

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