V
vsail
Guest
Hi, I am quite new with using Gamemaker 2. When I click the left button mouse multiple time, it got stuck on the attack state and not returning to free state. I have been looking anywhere and can not figure it out.
Does anybody know how to fix this issue?
Moving Script
Attack Script
Attack animation processor
Combo script
Step
Global left click
Thank you for your time and any help will be appreciated
Does anybody know how to fix this issue?
Moving Script
Code:
move_speed = 2;
hsp = 0;
vsp = 0;
if (inputRight){
if(inputShift){
image_speed = 2;
hsp = move_speed * 2;
} else {
image_speed = 1;
hsp = move_speed;
}
obj_Player.sprite_index = playerMWalkingRight;
strDir = "right";
} else if (inputLeft){
if(inputShift){
image_speed = 2;
hsp = -move_speed * 2;
} else {
image_speed = 1;
hsp = -move_speed;
}
obj_Player.sprite_index = playerMWalkingLeft;
strDir = "left";
} else if (inputUp){
if(inputShift){
image_speed = 2;
vsp = -move_speed * 2;
} else {
image_speed = 1;
vsp = -move_speed;
}
obj_Player.sprite_index = playerMWalkingBack;
strDir = "back";
} else if (inputDown){
if(inputShift){
image_speed = 2;
vsp = move_speed * 2;
} else {
image_speed = 1;
vsp = move_speed;
}
obj_Player.sprite_index = playerMWalkingFront;
strDir = "front";
} else if (inputShift){
image_speed = 0;
image_index = 0;
} else if (inputNull){
image_speed = 0;
image_index = 0;
}
if (inputMouseLeftInput){
scr_attack()
}
scr_collisionChecker();
show_debug_message("free");
x += hsp;
y += vsp;
Code:
hsp = 0;
vsp = 0;
currentSprite = sprite_index;
currentCollisionMask = mask_index
scr_processAttackAnimation(playerMSlashingFront,playerMSlashingBack,playerMSlashingLeft,playerMSlashingRight,
0,currentSprite,currentCollisionMask);
//replace 0 with weapon collision whe ready
//Combo active duration
if(inputMouseLeftInput && image_index > 3){
state = playerStates.combo;
}
if(animation_end()) {
sprite_index = currentSprite;
state = playerStates.free;
}
show_debug_message("attack");
Code:
currentSprite = argument5;
currentCollisionMask = argument6;
show_debug_message("before switch");
switch(strDir) {
case "front":
if(sprite_index != argument0) {
sprite_index = argument0;
image_speed = 1;
image_index = 0;
ds_list_clear(hitAttack);
strDir = "front";
}
break;
case "back":
if(sprite_index != argument1) {
sprite_index = argument1;
image_speed = 1;
image_index = 0;
ds_list_clear(hitAttack);
strDir = "back";
}
break;
case "left":
if(sprite_index != argument2) {
sprite_index = argument2;
image_speed = 1;
image_index = 0;
ds_list_clear(hitAttack);
strDir = "left";
}
break;
case "right":
if(sprite_index != argument3) {
sprite_index = argument3;
image_speed = 1;
image_index = 0;
ds_list_clear(hitAttack);
strDir = "right";
}
break;
}
show_debug_message("after switch");
mask_index = argument4 //hitbox's mask
hitAttackCurrent = ds_list_create();
hits = instance_place_list(x,y,0,hitAttackCurrent,false)
if(hits > 0) {
for(var i = 0; i < hits; i++){
//check instance colision with hitbox mask
var hitID = ds_list_find_value(hitAttackCurrent, i);
if(ds_list_find_index(hitAttack,hitID) == -1){
ds_list_add(hitAttack,hitID);
with(hitID){
scr_enemyHit(2);
}
}
}
}
ds_list_destroy(hitAttackCurrent);
mask_index = currentCollisionMask;
show_debug_message("after hitbox checkin");
Code:
hsp = 0;
vsp = 0;
currentSprite = sprite_index;
currentCollisionMask = mask_index;
scr_processAttackAnimation(playerMSlashingFront,playerMSlashingBack,playerMSlashingLeft,playerMSlashingRight,
spr_collider,currentSprite,currentCollisionMask);
//replace 0 with weapon collision whe ready
//Combo timer
if (inputMouseLeftInput) && (image_index > 3)
{
state = playerStates.combo;
}
if (animation_end())
{
sprite_index = currentSprite;
state = playerStates.free;
}
show_debug_message("multi");
Code:
scr_inputs();
switch(state) {
case(playerStates.free):
scr_moving();
break;
case(playerStates.attack):
scr_attack();
break;
case(playerStates.combo):
scr_multiAttack();
break;
}
Code:
state = playerStates.attack;