1
\$\begingroup\$

In Game Maker I am creating a 2D RPG and combat is a part of it. I have some animations that will play when the left or right mouse button is pressed (Depending on if you want ranged or melee attacks) but when a movement key (for example, D) is not pressed the animation won't play. Only when that key is pressed will the animation play, which is annoying as it ruins the fluid nature of the game. I'll post the code for pressing D and pressing RMB down (not A orLMB` because the code is identical, just reversed).

RMB:

if mouse_check_button(mb_right)
{
  if cusdirection = 0
  {
    if inair = true
    {
      //Do Nothing
    }
    else
    {
      hspeed = 0
      sprite_index = spr_qa_atk_bow_right
    }
  }
}

D:

if keyboard_check(ord("D"))
{
  hspeed = -5
  cusdirection = 0
  if inair = false
  {
    sprite_index = spr_qa_walk_right
  }
  else
  {
    sprite_index = spr_qa_inair_right
  }
}
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Could you please put your draw code? the problem could be there. \$\endgroup\$ – Alexandre Desbiens Jun 13 '15 at 21:02
  • \$\begingroup\$ Relevant: image_index \$\endgroup\$ – Alexandre Desbiens Jun 13 '15 at 21:03
  • \$\begingroup\$ I fixed it. Sorry about that. Incase anyone is interested, it was due to an idle animation and the attack animation being played at the same time, so because neither one settled it just didnt animate until I moved and the code changed. \$\endgroup\$ – LegoPokemon Jun 14 '15 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.