# FixSpriteToSkeleton2D

## Description

Attaches the specified sprite to the given skeleton and bone ID. The bone ID can be found by using the GetSkeleton2DBone command. When a sprite is attached to a skeleton bone then it's position and rotation become relative to the bone's position. For example if the sprite position was 0,0 then it would be drawn in the same position as the bone, but if the position was 0,10 then the sprite would be drawn above the bone, relative to the bone. i.e. if the bone is rotated left by 90 degrees then 'above' the bone would be to the left of the screen in world coordinates.
The ZOrder can be specified to draw the sprite in between two of the skeleton's existing sprites, any integer value is valid and corresponds to the current order of the sprites in the skeleton. For example a ZOrder of 0 would always draw before the first sprite in the skeleton's ZOrder, a value of 1 would always draw before the second sprite in the skeleton, and so on. Note that this ian't affected by other sprites you have attached to the skeleton, it only counts sprites that were originally loaded with the skeleton. For example if you fixed two new sprites to the skeleton both with a zorder equal to 1, then they would both be drawn between between the first and second sprites in the original skeleton. Any sprites that are attached to the skeleton using the same zorder value will be drawn in the order they were attached.
Whilst this sprite is attached to a skeleton it will be removed from the normal drawing routines and only drawn when the skeleton is visible. You can still force the sprite to draw by calling DrawSprite but it will not be ordered with the other sprites in the skeleton.
To detach a sprite from a skeleton call this command with 0 as the skeletonID, the bone ID and zorder parameters do not matter in this case.

## Definition

FixSpriteToSkeleton2D( spriteID, iSkeletonID, bone, zorder )

void agk::FixSpriteToSkeleton2D( UINT spriteID, UINT iSkeletonID, int bone, int zorder )

## Parameters

- spriteID - The ID of the sprite to attach
- iSkeletonID - ID of the skeleton to attach to
- bone - The ID of the bone in the skeleton to attach to
- zorder - The ZOrder to place the new sprite in the skeleton draw order