Change Frames like Compass Sprite in 8dir

Get help using Construct 2

Post » Sun May 13, 2012 7:07 am

I was experimenting some mechanics, but this one made waste my time a lot, i tried with it some expressions like pixel distance and angle position, but it didn't work.

There a concept pic what im talking about:



There an unresolved .capx contains 8 frames for yellow head sprite, it contains no events because i removed useless events that never work:


http://dl.dropbox.com/u/76227787/UnresolvedCompassSprite.capx

Can anyone help me :o?
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Post » Sun May 13, 2012 7:29 am

No idea of what you want, but I can tell you as far as angles go, 0 degrees would be frame 3, 45 degrees would be frame 2, 90 degrees would be frame 1, etc.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Sun May 13, 2012 8:02 am

[QUOTE=newt] No idea of what you want, but I can tell you as far as angles go, 0 degrees would be frame 3, 45 degrees would be frame 2, 90 degrees would be frame 1, etc.[/QUOTE]

But that's not point, it's like Rotate X degrees toward this donut object but only is changing animation frames without rotating sprite.
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Post » Sun May 13, 2012 12:57 pm

http://dl.dropbox.com/u/41931267/Donut.capx

I think this is what you are after?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sun May 13, 2012 3:23 pm

Clever solution, sqiddster! You seemed to have some duplicate frames (maybe wrong version on dropbox?) so I pasted the correct ones in place according to Joannesalfa's drawings, but in the order to match C2's rotation, as you said.

Donut2.capx
B
29
S
11
G
12
Posts: 281
Reputation: 11,868

Post » Sun May 13, 2012 4:30 pm

Oops, you are right! My animations must have gotten messed up at the last minute! Ah well, you can see the logic, the important thing to appreciate is the angle() expression, which you will come to appreciate ;)

B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sun May 13, 2012 11:07 pm

sqiddster and kittiewan, thank you for a great solution!

Apparently, i was figuring out to set animation instead of set frame, i got a type mismatch because it requires a string, not a expression like you did it.

I added an event like compare frame... but it didn't work :(


1-System| Every Tick:
--Sprite| Set Animation Frame to: floor((angle(sprite2.X,sprite2.Y,self.X,self.Y) + 180 + 22.5) / (360 / 8))

2-Sprite| Animation frame = 3:
--Sprite| Set animation to "Random Animation" (play from beggining)

Do you have ideas what i should to do?Joannesalfa2012-05-13 23:10:38
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Post » Mon May 14, 2012 10:32 pm

Isn't that possible?
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Post » Tue May 15, 2012 12:25 am

I'm not 100% sure what you're asking, but the following capx has changes to sqiddster's example to use animations instead of frames.

DonutAnimation.capx

Just concatenate the result of the expression onto a string to create the animation name string.kittiewan2012-05-15 00:26:12
B
29
S
11
G
12
Posts: 281
Reputation: 11,868

Post » Tue May 15, 2012 3:40 am

@kittiewan omg... i knew i should to add & as string and concatenate.

Thank you a lot! :D
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests