0 Favourites

[Solved]How do I reverse angle on button tap?

  • Hi everyone,

    I am trying have an event where button A is pressed, the sprite will turn 90 degrees clockwise and when the same button is pressed it will turn back to the original position which is -90 degrees from the new position.

    I set a global variable - rotation = 0 where button A is pressed, add 1 to rotation and check when rotation is 1, rotate -90 clockwise. However, it becomes a loop that causes the sprite to not turn at all. I guess the system check is instant. How do I work around this?

    Thanks,

    Clement

  • Remember events are read top to bottom. So how you have it, it is rotating the object 90 degrees then immediately rotating is back 90 degrees the other way if I'm looking at it correct.

    Check out this tutorial by Ashley to see a better way to set that up with an Else statement.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • C-7

    Yes. I know that's the case and I've been trying to get it to work based on Ashley's tutorial. But even using trigger once while true, set them to group and all other methods. Just can't seem to get this one to work. Regardless of whichever condition I use. It all goes back to a loop. I might not know some of the advanced technique yet though. I am looking at Else statement now. Thanks for pointing out.

    *Update* Got this to work with Else subevents. Thanks again!

  • C-7

    Yes. I know that's the case and I've been trying to get it to work based on Ashley's tutorial. But even using trigger once while true, set them to group and all other methods. Just can't seem to get this one to work. Regardless of whichever condition I use. It all goes back to a loop. I might not know some of the advanced technique yet though. I am looking at Else statement now. Thanks for pointing out.

    *Update* Got this to work with Else subevents. Thanks again!

    No problem! I try to post direct answers, but Ashley explained it really well, it's a common mistake that you made, and it's something great to know!

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