1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

Sprite Animation

Discussion in 'Game Design, Development And Publishing' started by squidsRockets, Oct 14, 2016.

  1. squidsRockets

    squidsRockets Member

    Joined:
    Oct 1, 2016
    Posts:
    12
    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)
     
  2. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,881
    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
     
  3. squidsRockets

    squidsRockets Member

    Joined:
    Oct 1, 2016
    Posts:
    12
    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.
     
  4. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,881
    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).
     
  5. DariusWolfe

    DariusWolfe Member

    Joined:
    Sep 23, 2016
    Posts:
    32
    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: Oct 20, 2016

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice