skeleton_attachment_replace

This function replaces an existing custom attachment on the current instance's skeletal animation sprite with another one.

The change to the attachment will be visible in all Slots that have the attachment assigned.

 

Syntax:

skeleton_attachment_replace(name, sprite, ind, xorigin, yorigin, xscale, yscale, rot);

ArgumentTypeDescription
nameStringThe name of the attachment to replace
spriteSprite AssetThe index of the sprite asset to use for the attachment
indRealThe image_index of the sprite to use
xoriginRealThe x origin to use for the image. The sprite's origin is ignored.
yoriginRealThe y origin to use for the image. The sprite's origin is ignored.
xscaleRealThe horizontal scale factor of the image
yscaleRealThe vertical scale factor of the image
rotRealThe rotation of the image. This is added to the bone's rotation.

 

Returns:

Real (1 if successful, -1 if not)

 

Example:

if (skeleton_attachment_exists("weapon_attachment"))
{
    skeleton_attachment_replace("weapon_attachment", spr_baseball, 0, 0, 0, 1, 1, 0);
}

The above code first checks if an attachment named "weapon_attachment" exists. If it exists, the attachment is replaced with a new one that uses a sprite "spr_baseball" and has no change in origin (offset), scale or rotation.