Rotating sprite 90 degrees at a time.

This forum is currently in read-only mode.
From the Asset Store
Avoid obstacles and survive as long as you can!
  • 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

    Any wizards still here?

  • 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.

  • 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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I didn't even see this post was in classic, sorry.

    I'm not sure if it will help or not:

    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.

  • 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.

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