GameMaker Making armor for the player

P

Pedau666

Guest
I wanted to make armor for the player (boots and breastplate) but when I added this simple code to draw the sprite on the player it draws pretty ugly and most of the time it has other animation than the player has. Sprite for the boots has exactly the same amount of frames as player and each frame is drawn to fit the players sprite. Do you know how to fix this problem?

o_armor step event
Code:
what.x = o_player.x;
what.y = o_player.y;


//animation
if(!place_meeting(x,y+1,o_solid))
{
    sprite_index = s_what_jump;
    image_speed = 0;
    if(sign(o_player.vsp)>0) image_index = 1; else image_index = 0;
}
else
{
    image_speed = 1;
    if(o_player.hsp==0)
    {
        sprite_index = s_what;
    }
    else
    {
        sprite_index = s_what_run;
    }
}

if(o_player.hsp != 0) image_xscale = sign(o_player.hsp);

//invincible
if o_player.inv > 0 {
   o_player.inv -= 1;
}


if(o_player.hsp != 0) image_xscale = sign(o_player.hsp);
In place of "s_what" I type the sprite I want to draw in create event and "what" is the object drawn.
 
C

Caique Assis

Guest
I think a better approach to this is to not create a object for every armor you want to draw on the player (even if you made it in a generic way) but to draw the armor on top of the player sprite in its own draw event. That way, on top of having the sprite always synched with the player, it'd be more optmized.

Of course, just remember to draw_self() on the obj_player draw event, because when you put any code into the draw event of a object, it overrides the default "draw the assigned sprite" behaviour.
 
Top