E
elikapika
Guest
So I've mostly been using Shaun Spalding's tutorials on GMS/GMS2, and I'm currently adding attacks into my platformer game. I have a standard attack so far, but I am trying to add others, such as when you attack in the air, attack with the down button, and so on. However, I'm not sure how to get these other attack states to work.
The code above is the normal attack, which does work. I thought using this same code for everything else and changing the different animations would still work.
The code in which would change the states would be this:
onGround is a variable that uses a script with the code
The result of doing anything but the normal attack results in the player character floating higher than a regular jump allows, and falls back down to the ground, but is still in the fall animation. Movement is locked once the player hits the ground.
Sorry if I messed anything up with my first time posting here, and I hope I don't make some people irritated with my use of tutorials and/or if this is a simple question.
Code:
vsp = 0;
hsp = 0;
if (sprite_index !=attack)
{
sprite_index = attack;
image_index = 0;
ds_list_clear(hitByAttack);
}
mask_index = hb;
var hitByAttackNow = ds_list_create();
var hits = instance_place_list(x,y,enemy,hitByAttackNow, false);
if (hits > 0)
{
for (var i =0; i<hits; i++)
{
var hitID = hitByAttackNow[| i];
if (ds_list_find_index(hitByAttack,hitID)== -1)
{
ds_list_add(hitByAttack,hitID);
with(hitID)
{
//what will happen to the enemy, currently does nothing ;
}
}
}
}
ds_list_destroy(hitByAttackNow);
mask_index = s_idle;
if (animation_end())
{
sprite_index = s_idle;
state = PLAYERSTATE.FREE;
}
The code in which would change the states would be this:
Code:
if (key_attack) state = PLAYERSTATE.ATTACK;
if (key_attack and !onGround) state = PLAYERSTATE.AIR_ATTACK;
if (key_attack and !onGround and keyboard_check_direct(vk_down)) state = PLAYERSTATE.DOWN_ATTACK_AIR;
if (key_attack and !onGround and keyboard_check_direct(vk_up)) state = PLAYERSTATE.UP_ATTACK_AIR;
if (key_attack and keyboard_check_direct(vk_down)) state = PLAYERSTATE.DOWN_ATTACK;
if (key_attack and keyboard_check_direct(vk_up)) state = PLAYERSTATE.UP_ATTACK;
Code:
return place_meeting(x,y+1,c);
Sorry if I messed anything up with my first time posting here, and I hope I don't make some people irritated with my use of tutorials and/or if this is a simple question.