Page 1 of 2

How do I Rotate Sprite?

PostPosted: Tue Apr 21, 2015 3:05 pm
by zikdot
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

Re: How do I Rotate Sprite?

PostPosted: Tue Apr 21, 2015 3:10 pm
by LittleStain
You can use rotate towards angle.
For example:

touch is touching object - rotate sprite 5 degrees towards sprite.angle+90

Re: How do I Rotate Sprite?

PostPosted: Tue Apr 21, 2015 3:16 pm
by LittleStain
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

Re: How do I Rotate Sprite?

PostPosted: Tue Apr 21, 2015 4:56 pm
by zikdot
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

Re: How do I Rotate Sprite?

PostPosted: Wed Apr 22, 2015 12:49 pm
by zikdot
@LittleStain any ideas? by the way thanks so much. You've been so hopeful with my problems

Re: How do I Rotate Sprite?

PostPosted: Wed Apr 22, 2015 1:21 pm
by korbaach

Re: How do I Rotate Sprite?

PostPosted: Thu Apr 23, 2015 3:09 am
by zikdot
Yeah that works perfectly. How do i increase the rotation speed though? @korbaach

Re: How do I Rotate Sprite?

PostPosted: Thu Apr 23, 2015 8:12 am
by LittleStain
Well there is the action set rotate speed..?

Re: How do I Rotate Sprite?

PostPosted: Thu Apr 23, 2015 8:52 am
by korbaach
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

Re: How do I Rotate Sprite?

PostPosted: Thu Apr 23, 2015 11:29 pm
by zikdot
Thank You!