1. 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

GM:S 1.4 animating sprite sheets

Discussion in 'Programming' started by koniption23, Nov 30, 2019.

  1. koniption23

    koniption23 Member

    Joined:
    Oct 29, 2019
    Posts:
    7
    Hello all when I am trying to animate using spr_index I either get results that when I press the right key the animation freezes then plays on release or the animation plays and player is stuck I have verified both the collision mask and the sprite origin but to no avail. heres one of the code variations I tried

    if(xprevious<x)
    {
    image_index=0;
    sprite_index= run_test;
    image_xscale=1;
    image_speed=1}


    if(xprevious>x)
    {
    image_index=0;
    sprite_index= run_test;
    image_xscale=-1;
    }
     
  2. shortbread

    shortbread Member

    Joined:
    Nov 28, 2019
    Posts:
    6
    You're resetting the image_index to 0 every time the object moves, which is why the animation is frozen when moving.

    If you want to reset the animation to the first frame when you start moving, place the image_index = 0; into a keyboard_pressed event so that it only executes on the initial press and doesn't keep setting the index to 0 while being held.

    You can also move all your existing statements into the same event.

    For example:
    Code:
    if (keyboard_check_pressed(vk_right)) {
       image_index = 0;
       sprite_index = run_test;
       image_xscale = 1;
       image_speed = 1;
    }
    
     
  3. koniption23

    koniption23 Member

    Joined:
    Oct 29, 2019
    Posts:
    7
    thank you I will give that a shot
     
  4. koniption23

    koniption23 Member

    Joined:
    Oct 29, 2019
    Posts:
    7
    thanks I added the code your provided to a step event and the run animation does not stop and the player is stuck in place any thoughts where I may have missteped?
     
  5. shortbread

    shortbread Member

    Joined:
    Nov 28, 2019
    Posts:
    6
    To stop the animation try this:
    Code:
    if (xprevious == x) {
    image_index = 0;
    image_speed = 0;
    }
    
    This will check is your player has NOT moved since the last step and stop the animation.
    In terms of collisions thats a whole other situation, I'd recommend you look at some tutorials on youtube for collisions etc.
     

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