How do I make a sprite rotate after my touch/mouse angle?

0 favourites
  • 12 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • Hello,

    I have a sprite with the drag and drop behavior. Everything is working as it should but I want my sprite to rotate, following my mouse/touch angle. I want my sprite (a little monster) to always look in the direction where I touch.

    I tried this method: DragDrop is dragging -> Sprite - Set angle to angle(Sprite.X, Sprite.Y, Touch.X, Touch.Y) degrees but it will only move once, it will not update its angle if I keep touching and I change this angle.

    Look at this game for example, so you can understand better:

    Thank you in advance!

  • You almost do it right, just add another condition: System > Every tick

    If it works, please tell me

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for your response.

    Unfortunately, I already tried that with no success. Still waiting for another idea.

  • Could you show me your capx?

  • Nothing too fancy in this file.

  • Small update. DragDrop is dragging -> Sprite - Set angle to angle(Sprite.X, Sprite.Y, Touch.X, Touch.Y) degrees condition is working fine, as that angle will never change until I modify the angle between the touch and my sprite.

    I need something else but I don't know how to implement. I just want this sprite to look after my mouse cursor/touch direction.

  • ionutzm05 - I think you need to look at the angle between where the Sprite was and where it is now (drag angle) instead of the angle between the Sprite and the Mouse/Touch.

    Here is an example capx r206

    Note 1: I rotate towards the angle (using dt) instead just setting the angle to avoid too much flickering

    Note 2: I flip the Sprite when angled left (90 to 270) so that it isn't upside down

    Note 3: On drop I return to angle 0

  • Thank you! This is what I was looking for.

  • I have problem that is connected to that behaviour.. my object (arm) is pinned to another object (body) because I want to rotate arms and legs by mouse move

    and has event:

    DragDrop is dragging -> Sprite - Set angle to angle(Sprite.X, Sprite.Y, Mouse.X, Mouse.Y)

    it is working.. but it is flickering

  • Dragot: Post your capx, and perhaps even create your own topic.

    Showing your code is always critical as it helps recreating your issue quickly and knowing where we start from.

  • Here is my playground:I have to say that I "meet" construct few days ago and I'm just trying to understand how it works and what can be done with it.. I like it so far


  • I got message: Dragot is not yet permitted to post plain text URLS (300 rep required)...

    so the file is on dropbox:

    https www dropbox com/s/km9kcub936ea17i/Simbra.capx?dl=0

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