How to rotate object to different angles easily??

Get help using Construct 2

Post » Thu Jan 24, 2013 7:32 pm

Hi C2 users:

Another question from a nub. Is there a way to easily rotate an object? That is,

1. user touches object. (this is for the iPad so I need to use touch and also mouse for testing--I've read that tutorial on how to use both so can probably figure that out)

2 object rotates 45 degrees.

3. Repeat rotation. (I want this to be an endless loop, but want the user to be able to control the rotation based on the touch)

I have used another similar program where this is fairly simple. I'm just not finding an easy way to do this in C2.

Since I'm new to C2, I'm looking for something that I'd be able to understand without a lot of background in the software.

TIA
B
6
S
1
Posts: 20
Reputation: 820

Post » Thu Jan 24, 2013 7:43 pm

- On Object1 touched
-> Set Sprite.angle to Sprite.Angle+45

- On Object2 touched
-> Set Sprite.angle to Sprite.Angle-45
B
40
S
12
G
7
Posts: 603
Reputation: 7,646

Post » Thu Jan 24, 2013 7:48 pm

You can test whether a finger touches on an object using the Touch -> On Touched Object event. Select the object you want to rotate, and in the events you add the Rotate clockwise (or counter-clockwise) action for the object.

If you want to test for the mouse however you should add the Mouse button is down condition, right click it and select add another condition. This time choose Cursor is over object. Then you can add the events to rotate the object.

Note; You can't simply use the 'mouse on object clicked' event because this way you'd have to click it multiple times to rotate it (and not instead holding the mouse button down).

If you want to allow the object to be only rotated to 45, 90, 135, 180, etc, you should be a little more specific. Do you want to make the object rotate immidiately 45 degrees after a second passes (and not smooth)? Or do you want it to rotate a little (eg 5 degrees) as long as the object is touched? In the last case, should it rotate to the nearest interval(-thing? 45 or 90 or 135 or etc)? Or should it always rotate upwards (so if the angle is say 60 and the object isn't touched anymore it automaticly rotates futher to 90).
B
13
S
3
G
4
Posts: 35
Reputation: 3,358

Post » Thu Jan 24, 2013 8:37 pm

Thank you. I will try to test these solutions out and get back with any further questions. I appreciate the help.

OK. Just tested this. EncryptedCow's solution works, but doesn't loop and uses two sprites. Maybe i'm missing something, but I would like to use one sprite and rotate it to angles whenever the user touches the object. For now, I think using the mouse is the best option. I can try out the touch later.

Jasper's solution is a little confusing for me.

I get this piece:

- Mouse Left Button is Down
-Mouse Cursor is Over Sprite

But don't understand "Then you can add the events to rotate the object." I add events and not actions?

I would like the object to freely rotate to any angle that the user wishes. Not sure how to set that up either. If that would be to hard for a nub to understand, maybe a rotation to by 45 degrees on each click or touch would work.


"If you want to allow the object to be only rotated to 45, 90, 135, 180, etc, you should be a little more specific. Do you want to make the object rotate immidiately 45 degrees after a second passes (and not smooth)? Or do you want it to rotate a little (eg 5 degrees) as long as the object is touched? In the last case, should it rotate to the nearest interval(-thing? 45 or 90 or 135 or etc)? Or should it always rotate upwards (so if the angle is say 60 and the object isn't touched anymore it automaticly rotates futher to 90)"

Thanks again for your help.
Just4fun2013-01-24 21:17:45
B
6
S
1
Posts: 20
Reputation: 820


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests