Jump to content


Photo

HALP! Animation Not Working!

gm:studio

Best Answer Mercerenies, 29 March 2016 - 02:21 AM

You want to be setting sprite_index, not image_index. sprite_index is the sprite to draw; image_index is the particular frame inside of that sprite to draw, so you're essentially resetting the frame to a constant value every step. Go to the full post


  • Please log in to reply
2 replies to this topic

#1 LoneWolfandProgrammer

LoneWolfandProgrammer

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 29 March 2016 - 01:57 AM

I need help. My player doesn't have a moving animation even though I did nothing wrong.(?) Please help! Here is the code:

 

if(keyboard_check(vk_up) && place_free(x,y-1) = true)
{
    y-=4;
    image_index = spr_playerbackward;
    image_speed = .2;
}
 
if(keyboard_check(vk_down) && place_free(x,y+1) = true)
{
    y+=4;
    image_index = spr_playerforward;
    image_speed = .2;
}
 
if(keyboard_check(vk_right) && place_free(x+1,y) = true)
{
    x+=4;
    image_index = spr_playerright;
    image_speed = .2;
}
 
if(keyboard_check(vk_left) && place_free(x-1,y) = true)
{
    x-=4;
    image_index = spr_playerleft;
    image_speed = .2;
}
 
if(!keyboard_check(vk_up) && !keyboard_check(vk_down) && !keyboard_check(vk_right) && !keyboard_check(vk_left))
{
    image_index = spr_player_idle;
    image_speed = 0;
}

  • 0

#2 Mercerenies

Mercerenies

    Koopa King

  • GMC Member
  • 1945 posts
  • Version:GM:Studio

Posted 29 March 2016 - 02:21 AM   Best Answer

You want to be setting sprite_index, not image_index. sprite_index is the sprite to draw; image_index is the particular frame inside of that sprite to draw, so you're essentially resetting the frame to a constant value every step.
  • 0
iPqfGiP.png

#3 LoneWolfandProgrammer

LoneWolfandProgrammer

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 29 March 2016 - 02:30 AM

Thanks!


  • 0





Also tagged with one or more of these keywords: gm:studio