» Uncategorized Posts

sprite_change_collision_mask

Updates collision mask properties of the sprite asset loaded from the /sprites folder.

ArgumentTypeDescription
sprite:stringThe name of the sprite to set the bounding box of
sepmasks:realWhether to create collision masks for each sub-image of the sprite (true) or one mask for all (false)
bboxmode:realThe kind of bounding box:
0 = automatic
1 = full image
2 = user defined
bbleft:realThe maximum left position of the bounding box
bbtop:realThe maximum top position of the bounding box
bbright:realThe maximum right position of the bounding box
bbbottom:realThe maximum bottom position of the bounding box
kind:realThe kind of mask:
0 = precise
1 = bounding box
2 = disk
3 = diamond

Example, called from init.gml:

// changing offset of the jump sprite to [94, 138]:
sprite_change_offset( "jump", 94, 138 );
// making it precise:
sprite_change_collision_mask( "jump", true, 0, 0, 0, 0, 0, 0 );

sprite_change_offset

Changes the x and y offset (origin) of the sprite asset loaded from the /sprites folder. Coordinates are relative to the (0,0) position being the upper left corner of the sprite. The following image illustrates this:

ArgumentTypeDescription
sprite:stringThe name of the sprite to change the offset of
xoff:realThe x position of the origin
yoff:realThe y position of the origin

Example, called from init.gml:

// changing offset of the jump sprite to [94, 138]:
sprite_change_offset( "jump", 94, 138 );
// making it precise:
sprite_change_collision_mask( "jump", true, 0, 0, 0, 0, 0, 0 );

sprite_get

Returns the unique index (real) of the sprite asset loaded from the /sprites folder.

ArgumentTypeDescription
sprite:stringThe name of the game asset to get the index of

Example, called from animation.gml:

if (state == PS_WALK) {
sprite_index = sprite_get( "dash" );
}

take_damage

Deals damage to the specified player.

ArgumentTypeDescription
damaged_player:realPlayer number of the player to damage
attacking_player:realAttacker's player number. Only used for stat tracking, and should be set to -1 if the damage is not from another player
damage:realThe damage to deal. Negative damage values will heal the player instead

Example, called from attack_update.gml:

// heals 10 damage to self:
if (attack == AT_NSPECIAL) {
if (window == 4 && window_timer > 30 && window_timer < 41) {
take_damage( player, -1, -1 );
}
}

set_player_damage

Sets the amount of damage for the specified player.

ArgumentTypeDescription
player:realID of the player to set the damage of
value:realThe value to set

Example, called from attack_update.gml:

// fully heals your character at the end of window 2:
if (window == 2 && window_timer == 200) {
set_player_damage( player, 0 );
}