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

Get help using Construct 2

Post » Thu Jul 30, 2015 1:38 pm

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: coolgames.com/en/spinytom.html.

Thank you in advance!
B
3
Posts: 5
Reputation: 185

Post » Thu Jul 30, 2015 4:59 pm

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

If it works, please tell me :)
B
6
S
1
Posts: 11
Reputation: 448

Post » Thu Jul 30, 2015 5:38 pm

Thanks for your response.

Unfortunately, I already tried that with no success. Still waiting for another idea.
B
3
Posts: 5
Reputation: 185

Post » Thu Jul 30, 2015 7:35 pm

Could you show me your capx?
B
6
S
1
Posts: 11
Reputation: 448

Post » Thu Jul 30, 2015 7:57 pm

Nothing too fancy in this file.

dropbox.com/s/mnjillgk1f9budy/Drag_drop.capx
B
3
Posts: 5
Reputation: 185

Post » Fri Jul 31, 2015 12:31 pm

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.
B
3
Posts: 5
Reputation: 185

Post » Fri Jul 31, 2015 1:51 pm

@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
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 467
Reputation: 6,864

Post » Fri Jul 31, 2015 6:27 pm

Thank you! This is what I was looking for.
B
3
Posts: 5
Reputation: 185

Post » Tue Dec 08, 2015 7:07 am

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 :(
B
3
Posts: 5
Reputation: 185

Post » Tue Dec 08, 2015 10:35 am

@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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
293
S
117
G
96
Posts: 7,310
Reputation: 71,069

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests