skeleton_slot_data(sprite, list);
Argument | Description |
---|---|
sprite | The sprite index of the Spine skeletal animation to get the data from. |
list | The ID of the DS list to populate with the DS maps. |
Returns: N/A
With this function you can populate a (pre-created) ds_list with data for each of the available attachment slots that an animation contains. This data is returned in the forum of a ds_map which contains the following key/value pairs:
- "name": The name of the slot.
- "bone": The name of the bone.
- "attachment": The name of the attachment if one is used or "(none)" if there isn't one assigned.
The values for each key will be strings and can then be used in the other skeleton attachment functions for these types of sprite. Note that the ds_map created are not destroyed so you will need to loop through the ds_list and destroy each of the created maps yourself.
IMPORTANT: Spine integration in GameMaker: Studio is a Pro licence feature and will not work in the Free/Standard versions.
var list = ds_list_create();
var open = true;
slot_name = "";
skeleton_slot_data(sprite_index, list);
for (var i = 0; i < ds_list_size(list); i++;)
{
var map = list[| i];
if open
{
if map[? "attachment"] ==
"(none)"
{
open =
false;
slot_name =
map[? "name"];
}
}
ds_map_destroy(map);
}
ds_list_destroy(list);
The above code creates a DS list and then populates it with the slot data for the instance sprite. This data is then parsed to extract the individual DS maps with the slot data. This is then checked to see if there is an empty slot, and if so the variable "slot_name" is assigned the empty slot name before the DS map is destroyed. Finally we destroy the DS list as it is no longer required.