• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Sprite Animation

S

squidsRockets

Guest
I am just wondering how I should handle sprite animation. I'm not doing it (friend is doing art and animation for the game), so I've been coding and right now I have the items I pick up to follow the player (behind the player, so you can't see them) and the items themselves are the things doing all the action. But once I get an animated sprite how do I make it all work and look right? (the game is a side scroller)
 

Yal

🐧 *penguin noises*
GMC Elder
What looks "right" is kinda subjective and it's hard to give a general answer... could you elaborate a bit?
  • If you're worried the items will be visible behind the player, you can turn them invisible using the visible variable when they're carried but not in use.
  • If you're worried about animations, you could have each item check what sprite the player is currently using and then move to the right position depending on its image (e.g. make a sword follow the character's hand, but only when they're in a sword attack animation)
  • If you're worrying about something else... well, ask that :p
 
S

squidsRockets

Guest
What looks "right" is kinda subjective and it's hard to give a general answer... could you elaborate a bit?
  • If you're worried the items will be visible behind the player, you can turn them invisible using the visible variable when they're carried but not in use.
  • If you're worried about animations, you could have each item check what sprite the player is currently using and then move to the right position depending on its image (e.g. make a sword follow the character's hand, but only when they're in a sword attack animation)
  • If you're worrying about something else... well, ask that :p
I'm mainly worried about projectiles, because right now my player is a 32x32 box and bullets come out of the center of that (where the stacked gun is) but if I have a taller sprite holding a gun, I want the bullets to look like they are leaving from his gun.
 

Yal

🐧 *penguin noises*
GMC Elder
If you're following the player around, you have some way to access their variables from inside the guns, right? You can also access their sprite_index variable and decide based on that (e.g. create the bullets higher up if the player has a certain sprite, or if their sprite_height is bigger than 32 pixels).
 
D

DariusWolfe

Guest
If the gun will always be at a specific location, regardless of the sprite, then it's easy enough to use instance_create(x+a,y+b,obj_projectile) where a and b will offset the position to where the gun barrel will be positioned. A lot of games do this by using a specific sprite for the shooting animation. If the gun will be in different positions when firing, then you might use something like a case statement:

switch image_index
{
case 0: a=5; b=7; break;
case 1: a=6; b=6; break;
case etc...
}
 
Last edited by a moderator:
Top