G
gurglovt
Guest
I have a player character consisting of 2 objects (oPlayer and oArms) and while states work for oPlayer, oArms seems to not respond to them:
Controller object Create event:
oPlayer step event:
oArms Step event:
Any ideas? thanks in advance!
Controller object Create event:
GML:
enum states
{
idle,
walk,
attack,
parry
}
Code:
if (state == states.idle)
{
#region Idle
//Function
if moving = true
{
state = states.walk;
}
if key_attack
{
state = states.attack;
}
if key_parry
{
state = states.parry;
}
//Sprites
sprite_index = sPlayer_Idle;
#endregion
}
else if (state == states.walk)
{
#region Walk
//Function
if moving = false
{
state = states.idle;
}
if key_attack
{
state = states.attack;
}
if key_parry
{
state = states.parry;
}
//Sprites
sprite_index = sPlayer_Walk;
#endregion
}
else if (state == states.attack)
{
#region Attack
//Function
global.attacking = true;
if global.attacking = false
{
state = states.idle;
}
//Sprites
sprite_index = sPlayer_Idle;
#endregion
}
Code:
x = oPlayer.x;
y = oPlayer.y;
image_angle = point_direction(x,y,mouse_x,mouse_y);
if (state == states.idle)
{
#region Idle
//Sprites
sprite_index = sPlayer_Arms_Idle;
#endregion
}
else if (state == states.walk)
{
#region Walk
//Sprites
//currently set to an animated sprite to see if state changes when just walking
sprite_index = sPlayer_Arms_Parry;
image_speed = 1;
#endregion
}
else if (state == states.attack)
{
#region Attack
//Function
sprite_index = sPlayer_Arms_Attack;
if image_index >= 3
{
with (instance_create_depth(x,y,1,oArrow))
{
move_towards_point(mouse_x,mouse_y,oArrow.spd);
}
global.attacking = false;
}
//Sprites
sprite_index = sPlayer_Arms_Attack;
#endregion
}
Last edited by a moderator: