Well let's start with how to make two different sprites sync up.
I bet you didn't even notice that the glowing parts of the normal player sprite and the one when you fire match.
It's simple, use a variable to keep track of what frame the animation is on and when you need to swap sprites have it use that variable to skip to the appropriate frame.
This is all in the Step Event
if sprite_var < 15
then sprite_var = sprite_var + 1
else sprite_var = 0 [1]
if s = 0 [2]
then {sprite_index = players [3]
image_index = sprite_var
image_speed = 0}
else {
if s = 1
then {sprite_index = playershoots
image_index = sprite_var
image_speed = 0}} [4]
![]() |
Thanks to that code these two separate sprites sync up. |
I'm sure there's a better way of doing it but that's how I figured it out.
Hmmm what else to cover?
Ahhh, here's a quick one most of you should know, but beginners may find useful.
The health bar. The way it works is that player hp is tracked by another global variable. As you've seen before the frame of animation in a sprite can be changed via variable... put two and two together and you get-
image_index = global.hp_player [5]
image_speed = 0 [6]
Put this into the step event of your health bar object, and voila a custom health bar
The experience bar works the same way.
That's enough for now I think, at the rate I'm churning out posts part three should be out in a few hours or so.
1:This is the code that tells what frame the animation is on, obviously there are 16 [1a] frames.
1a:Frame count starts with 0.
2:The variable s is short for shooting and is used to keep track of when you are firing the guns, and thus when to change the sprite.
3:I add an s at the end of the name of sprites to differentiate them from objects .
4:In English, if not firing then use the standard sprite with frame equaling the sprite variable, and an animation speed of zero, otherwise if you are firing then swap to the firing sprite and do the same.
5:You'll need to draw one frame for each hit you can take, with frame 0 being an empty health bar.
6:This is how you keep the health bar from cycling through all it's frames.
No comments:
Post a Comment