How do I make it when a object clicked, it goes to the next frame.

0 favourites
  • 10 posts
From the Asset Store
The ultimate voice pack filled with 1,536 files of .......wav and mp3 of individual numbers, letters, and words (that go
  • How do I make it when a object clicked it will go to the next frame?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • On Object Clicked --------------Action: object set frame to self.frame + 1

  • Is there a way for it to loop so when it goes to frame 1 it goes back to frame 0?

  • Is there a way for it to loop so when it goes to frame 1 it goes back to frame 0?

    If you need to loop back just once on click then you could just do:

    On Click object:

    -----------------Set Frame to 1

    -----------------Wait 1 second

    -----------------Set Frame to 0

    If you need it to loop forever then open the animation on the Animation editor and tick the box "Loop", which is at the Bottom right

  • I mean when its at 1 when clicked again it goes back 0.

  • I mean when its at 1 when clicked again it goes back 0.

    Assuming that you have just two frames you could do:

    On Object Clicked: ---------- Set Frame to: (Self.AnimationFrame +1) % Self.AnimationFrameCount

    ==========================================================================

    Also, you can do it by adding Conditions check:

    On Object Clicked:

    Subevent------Sprite.Frame = 0 --------------- Set Frame 1

    Subevent------Else --------------- Set Frame 0

  • Thanks so much it works! : D What does the percent mean in at the end though for the code? Im just curious so I can understand it better.

  • Thanks so much it works! : D What does the percent mean in at the end though for the code? Im just curious so I can understand it better.

    Np

    The percentage will just make sure that once you reach the last frame will loop back to 0, this is to save in making extra lines of events, other ways you will have to add more condition checks like the second option I posted above.

  • Ok! Thanks!

  • Actually, that explanation is a bit lacking.

    The % sign in most common programming languages is modulo

    Remember when you first learned to divide, we would go "5 divided by 2 = 2 remains 1"

    Modulo is that "remains x".

    So yes, it will wrap around the values, but it has a lot of other super useful uses.

    Some quick examples:

    4 % 3 = 3

    4 % 2 = 0

    5 % 6 = 5

    5 % 0 = error

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