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

Just started using Construct 2? Post your questions here

Post » Fri Aug 07, 2015 3:01 am

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
Last edited by mrneko on Fri Aug 07, 2015 3:02 pm, edited 2 times in total.
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

Post » Fri Aug 07, 2015 3:18 am

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.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Fri Aug 07, 2015 3:38 am

@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!
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

Post » Fri Aug 07, 2015 4:35 am

mrneko wrote:@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!
B
103
S
38
G
19
Posts: 962
Reputation: 17,996


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests