Set an animation frame between angles using 8Direction

Get help using Construct 2

Post » Thu Nov 27, 2014 6:12 pm

I've been trying to figure this out all night and its driving me insane. I've read the tutorials on isometric and on 8Direction animation and i can't get what i'm looking for.

I have 8 individual frames (i've put them on in one image for this post, but they're separate frames. I also, messed up and switched frame 5-6 in the illustration)
angles.png


All I want is for the animation frames to line up properly with which key was pressed.
I have it so the first frame is facing right and is set to 0° so, I figured if i broke 360° into 45° chunks i could check the players angle and have it snap to the frame.
anglescode.png


The images were rendered out in Blender with the camera set to 45° isometric angle. so, i'd like the sprite to stay heads up and change the frame based on the angle for all 8 directions.

Could anyone help me with this? :oops:
You do not have the required permissions to view the files attached to this post.
B
13
S
2
G
1
Posts: 47
Reputation: 1,211

Post » Thu Nov 27, 2014 6:53 pm

You have 7 angles, so 360/7= 51
Lets say at angle 0 the animation would be frame 0 if you renamed the frames from 0-6 rather than 1-7
If we were to say the angle was 180 we could say that the angle/51 = 3, or the 4th frame.
The frames system is pretty good at rounding things, but it would be wise to get just the whole numbers using int().

Edit:
Just realised you are using 8 frames. Didn't see them all, forum scrolls images.
So divide by 8 rather than 7.
Image ImageImage
B
172
S
50
G
183
Posts: 8,443
Reputation: 115,605

Post » Thu Nov 27, 2014 7:11 pm

Yeah, but 360 / 8 = 45° which is what i am currently doing. with the, "is between" conditions in the OP. If i'm misunderstanding, could you post an example possibly? Like I said, I've tried doing it multiple ways even using flags so when 'W' and 'D' or 'A' are pressed together, switch to NE or NW frame.
B
13
S
2
G
1
Posts: 47
Reputation: 1,211

Post » Thu Nov 27, 2014 7:17 pm

No need for the comparison.
Just set the frame to the angle
frame = int(angle/45)
Image ImageImage
B
172
S
50
G
183
Posts: 8,443
Reputation: 115,605

Post » Thu Nov 27, 2014 8:32 pm

okay, so i've done what you said with setting the frames based upon the angle (0/45,45/45,90/45,135/45...etc)
Where I'm confused is, what should the condition be since we are no longer comparing if the player is within a range of angles? Sorry if this seems obvious, i'm just not getting it. :?
angles.png
You do not have the required permissions to view the files attached to this post.
B
13
S
2
G
1
Posts: 47
Reputation: 1,211

Post » Thu Nov 27, 2014 8:40 pm

You're using angles wrong. They go from -180 to 180. Change the numbers and it should work fine. Remember that, for the left direction you should check for less than -157.5 OR greater than 157.5!
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
21
S
6
G
3
Posts: 664
Reputation: 3,855

Post » Thu Nov 27, 2014 8:42 pm

There is only one event.
sprite set frame to int(sprite.angle/45)

@brunopalermo

That would only apply if say you were using angle(x1,y1,x2,y2).
Image ImageImage
B
172
S
50
G
183
Posts: 8,443
Reputation: 115,605


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests