How to prevent sprite rotation for 8-dir movement

Get help using Construct 2

Post » Thu Jan 19, 2012 5:30 am

Okay, here's what I've done:

1. I used the jeep sprites from the 'battlefield' sprite pack to create a Jeep object with animations for moving up, down, left, right, etc.

2. I assigned 8-direction movement to the Jeep.

3. I created keypress events so that pressing up/down/left/right would set the right animation.

My problem is that whenever you move, the sprite rotates. But since the animations are already "pre-rotated", you end up with a very wrong sprite (like the 'up' animation rotated on its side).

What's the best way to fix this? I can't find an elegant way to disable rotation. Should I just set a per-frame event to force the Jeep's angle to zero? Or would that screw up other things (like created bullets would inherit angle zero too, regardless of the direction we're going)?
B
11
S
2
G
1
Posts: 8
Reputation: 1,414

Post » Thu Jan 19, 2012 5:34 am

Easiest solution that comes to mind: have an invisible "Player" sprite that has the 8dir movement, and have the Jeep sprite attached to it by way of "Every tick: Jeep - Set position to Player.X, Player.Y".

It's a handy trick for many types of games when it comes to controlling animations.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Thu Jan 19, 2012 6:31 am

Make sure that in the properties of the 8 direction behavior you have set the "Set angle" property to "No".

From the manual
[quote]Set angle
Whether or not the movement should also affect the objects angle. 360 degree (smooth) will always set the object's angle to the current angle of motion. 45-degree intervals will set the object's angle to 8 possible directions. 90-degree intervals will set the object's angle to 4 possible directions. No means the behavior will not set the object's angle at all, which is useful if you want to control this yourself with events (e.g. to make the object point towards the mouse cursor).[/quote]
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Thu Jan 19, 2012 9:42 pm

Is there a good solution for adjusting the animation frame for isometric sprites in that case?

In my code I do it like this:
+For every Jeep:
->Set Animation Frame= (Self.CustomMovement.Angle>45 & Self.CustomMovement.Angle<135) ? DOWN_SPRITE_FRAME : Self.Frame
->Set Animation Frame= (Self.CustomMovement.Angle>=135 & Self.CustomMovement.Angle<225) ? LEFT_SPRITE_FRAME : Self.Frame
etc.
B
12
S
3
G
3
Posts: 73
Reputation: 2,647

Post » Thu Jan 19, 2012 11:35 pm

r0j0 did that a while ago.. might answer your question
r0j0_8dir.capx
Last edited by Yann on Sun Sep 14, 2014 9:54 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Jan 19, 2012 11:57 pm

Ooooh clever. I like it
B
12
S
3
G
3
Posts: 73
Reputation: 2,647


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests