• 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!

Legacy GM How to perform attack animation while holding left mouse button?

M

mrjonwc

Guest
I want to perform a continued attack animation when holding down the left mouse button.

I figured I can set an alarm on if mouse check but this isn’t working.
 
V

VagrantWhaleGames

Guest
Use a state machine to control when and what animation to play.

Code:
if(mouse_check_button(mb_left))
{
state="attack"
}
else
{
state="idle"
}

switch(state)
{
case "idle":
sprite_index=sprPlayerIdle;
break;
case "attack":
sprite_index=sprPlayerAttack;
break;
}
 
Last edited by a moderator:

Sk8dududu

Member
A lot less work to just not use switch for a couple of actions.
But the basic idea is there, the "mouse_check_button(mb_left)" function just checks if you are currently holding your mouse button down. And then you can give it an action..
Step event
Code:
if mouse_check_button(mb_left)
{
Sprite_index=spr_atk;
}
else
{
Sprite_index = spr_idle;
}
 
Top