Rotating sprite 90 degrees at a time.

For questions about using Classic.

Post » Mon Aug 03, 2015 6:25 pm

My issue is rather simple (i think):

I am trying to make a system where when the player presses right arrow, the sprite rotates 90 degrees clockwise and stops (rotating), and the same for left arrow and counter-clockwise. For some reason my brain locks up trying to solve this action. So basically, the sprite would have only 4 angles, up, down, left, right. I can easily get it to work with "set angle", but it doesn't really look or feel nice, it needs to have a seamless rotation and thats the issue.. I guess this is laughably simple and easy to do task, but i'm kind of stuck :oops:

Any wizards still here?
B
4
S
2
G
2
Posts: 109
Reputation: 1,318

Post » Mon Aug 03, 2015 9:34 pm

Something like this? It's very simple, but could be the start of something.
https://dl.dropboxusercontent.com/u/85412219/forumposts/KeyRotate.capx

change rotate 1 degree to 3 or 6 for faster turns. It will switch directions if the current "direction" is closer in the other direction.
B
242
S
63
G
33
Posts: 903
Reputation: 40,756

Post » Mon Aug 03, 2015 9:57 pm

Thanks for replying!

Unfortunately i can't open the file since i don't have C2 (yet, but i will some day), i'm still toying around with Classic.
May i ask if you could paste the code here, it would still be very helpful?
B
4
S
2
G
2
Posts: 109
Reputation: 1,318

Post » Tue Aug 04, 2015 12:48 am

I didn't even see this post was in classic, sorry.
I'm not sure if it will help or not:
Image

The sprite has an instance variable named "Direction" that is set instead of angle, and angle is slowly rotated to the sprites "Direction" variable.
"Text" is just a text box showing the current direction.
B
242
S
63
G
33
Posts: 903
Reputation: 40,756

Post » Wed Aug 05, 2015 7:49 pm

Thanks!

Although i didn't manage to use that code directly, since classic seems to be missing that "rotate towards sprite.direction" expression, but i was able to come up with a rough workaround, but atleast now it works like i was hoping.
B
4
S
2
G
2
Posts: 109
Reputation: 1,318


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests