How do I Rotate Sprite?

Get help using Construct 2

Post » Tue Apr 21, 2015 3:05 pm

Now i have a sprite and it gets rotated 90 degrees every time a specific button is pressed. Now it works fine and the coding is simply

on touched object > rotate sprite 90 degrees clockwise

What i dont like is that it rotates without any kind of animation (can't think of the word i'm trying to use).
Basically when it rotates I want to be able to see the "frames" so to speak between each rotation to make it look more realistic.

Hope i'm making sense
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Tue Apr 21, 2015 3:10 pm

You can use rotate towards angle.
For example:

touch is touching object - rotate sprite 5 degrees towards sprite.angle+90
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Apr 21, 2015 3:16 pm

if you'd rather have the rotation performed on 1 touch

add a boolean instance variable rotating
and an instance variable OriginalAngle

on touched object > sprite set boolean rotating to true

sprite is rotating
-system compare two values - sprite.angle < sprite.OriginalAngle+90
> sprite rotate towards - sprite.OriginalAngle+90
-system else
> sprite set rotating to false
> sprite set value OriginalAngle = sprite.angle
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Apr 21, 2015 4:56 pm

for...... on touched object > sprite set boolean rotating to true.......It says i must add an instant variable first? i have made the instant variable that you said?

and then for......-system compare two values - sprite.angle < sprite.OriginalAngle+90.......It says OriginalAngle is not an expression
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Wed Apr 22, 2015 12:49 pm

@LittleStain any ideas? by the way thanks so much. You've been so hopeful with my problems
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Wed Apr 22, 2015 1:21 pm

B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Thu Apr 23, 2015 3:09 am

Yeah that works perfectly. How do i increase the rotation speed though? @korbaach
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Thu Apr 23, 2015 8:12 am

Well there is the action set rotate speed..?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Apr 23, 2015 8:52 am

zikdot wrote:Yeah that works perfectly....


Its far from perfect....if you drastically increase the speed..most likely sprite would miss checkpoint..
and continue to rotate...

...maybe you should check Rex's plugins for Construct2... http://c2rexplugins.weebly.com/rex_rotateto.html
it's a custom behavior with with more options than official Rotate behavior...

I think that would be the best option for you....

capx:
http://s000.tinyupload.com/index.php?fi ... 9930811473
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Thu Apr 23, 2015 11:29 pm

Thank You!
B
8
S
2
Posts: 146
Reputation: 1,132

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests