Sprite animation: not working as I want.

Post your own tutorials, guides and demos.

Post » Tue Jan 13, 2009 11:16 am

Right, I've got a test sprite set for platform style movement with a single two frame animation, facing in two angles, 0 and 180. However, when I run the test, the animation isn't turning around. I suspect I've omitted something very simple, but I'm not sure what.

Interestingly enough, auto mirror doesn't flip it around either. This does lend some suspicion this might be a bug of some kind. This is, by the way, originally a Construct 0.98.3 file upgraded to .5, if that helps at all.

Suggestions?
B
2
S
2
G
3
Posts: 158
Reputation: 1,566

Post » Tue Jan 13, 2009 12:44 pm

This is weird. Starting from scratch. Recreated the test sprite with the same two frame animation. Auto flip doesn't work, defining angles for 0 and 180 doesn't work either. Any ideas as to what's up?
B
2
S
2
G
3
Posts: 158
Reputation: 1,566

Post » Tue Jan 13, 2009 1:09 pm

When running the original test through the debugger, the angle it says the sprite is when moving to the left is 0 - it isn't using the 180 degree rotation for the sprite.

Help?
B
2
S
2
G
3
Posts: 158
Reputation: 1,566

Post » Tue Jan 13, 2009 3:19 pm

I think this has always been the case, but I could be wrong. You need to set the angles yourself, determining it based on the X velocity of the object. For example:

[code:lzkpz6p5]+If Guy[Platform].VectorX is greater than 0, Set Guy.Angle to 0
|
+Else, Set Guy.Angle to 180[/code:lzkpz6p5]
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Tue Jan 13, 2009 3:27 pm

Easy solution to this: program it yourself. :) Something like:

[code:2k6721ww]if Key "Left Arrow" is down AND Key "Right Arrow" is not down
Sprite: set Angle to 180
if Key "Right Arrow" is down AND Key "Left Arrow" is not down
Sprite: set Angle to 0[/code:2k6721ww]

Not that hard to add that in :o

EDIT: But going based on velocity like Linkman's example is probably a better way to do it actually because it would take friction into account of which way you were facing. :P (You posted while I was posting! D:)
B
1
G
4
Posts: 7
Reputation: 1,039

Post » Tue Jan 13, 2009 3:50 pm

Ah.

I was remembering the answers I got viewtopic.php?f=16&t=2380 in this thread, and thought (perhaps naively) that that would apply across different behaviour types.

[quote="linkman2004":1tdsp9ft][code:1tdsp9ft]+If Guy[Platform].VectorX is greater than 0, Set Guy.Angle to 0
|
+Else, Set Guy.Angle to 180[/code:1tdsp9ft][/quote:1tdsp9ft]

Pardon the excessive noobiness here, but erm... which condition(s) would allow me to do that? I'm probably staring it in the face but have no idea which one it might be...
B
2
S
2
G
3
Posts: 158
Reputation: 1,566

Post » Tue Jan 13, 2009 4:24 pm

And now to answer my own question!

If I do:
[code:28gf87w5]pick by sprIvoRobotnik [Platform].VectorX>0
sprIvoRobotnik: set angle to 180
else
sprIvoRobotnik: set angle to 0[/code:28gf87w5]
Movement works as expected using this.

That said, I'm clearly (not) doing something else I should be, because once movement ends the sprite returns to the default angle. Ideas?
B
2
S
2
G
3
Posts: 158
Reputation: 1,566

Post » Tue Jan 13, 2009 4:32 pm

You want to use the standard "Compare" event in the system object.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Tue Jan 13, 2009 4:44 pm

Using the system compare condition...

Now, I have:
[code:syg8w1sk]sprIvoRobotnik [Platform].VectorX Greater than 0
sprIvoRobotnik: Set angle to 0
else
sprIvoRobotnik: Set angle to 180[/code:syg8w1sk]
but it is still showing the reversion behaviour.

Any clues?
B
2
S
2
G
3
Posts: 158
Reputation: 1,566

Post » Tue Jan 13, 2009 4:56 pm

Okay, that one's partially my fault. The Else condition isn't proper here, as it will be setting the angle to the left if you're not moving. You want to do this, instead:

EVENT ONE:
sprIvoRobotnik [Platform].VectorX GREATER than 0
sprIvoRobotnik: Set angle to 0

EVENT TWO
sprIvoRobotnik [Platform].VectorX LESS than 0
sprIvoRobotnik: Set angle to 180

That should fix it. Also, with the Else condition, it's supposed to be placed directly under the event it effects, not as a subevent. Sorry for all of the confusion here.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Next

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 2 guests