I'm developing a combo system for the player so when the player presses x multiple times he preforms a combo. The combo system is working when the player presses the x button multiple times slowly. but when mashing the x button it goes to the second sprite before the animation ends. I've also tried some other ways of doing it but with no luck.
Here is the best I could come up with after a lot of research and debugging:
Create event:
attack = false;
//timer veriable used for combos
comboTimer = 0;
combo = 0;
step event:
///Attack mechanic
comboTimer -= 1;
if(comboTimer < 0){
combo = 0;
}
//show_debug_message(image_index);
if (attackKey){
comboTimer = 15;
if (combo == 0) {
attack = 1;
combo += 1;
sprite_index=spr_thief_attack;
image_index=0;
image_speed = 0.2;
alarm[0]=20; exit;
}
if (combo == 1) {
attack = 1;
combo += 1;
sprite_index=spr_thief_attack_combo1;
image_index=0;
image_speed = 0.2;
alarm[0]=10; exit;
}
if (combo == 2) {
attack = 1;
combo += 1;
sprite_index=spr_thief_attack_combo2;
image_index=0;
image_speed = 0.2;
alarm[0]=10; exit;
}
}
if(combo > 2){
combo = 0;
}
Alarm 0 event:
I would also appreciate it if someone pointed me to some good practices in implementing combo animations if this code is not good enough.
I'm also wondering if ending the animation before going to the next sprite in combo systems is good game design or not.
Any help would be appreciated.