Struct rusty_spine::Skeleton
source · pub struct Skeleton { /* private fields */ }
Expand description
A live Skeleton instance created from SkeletonData
.
Implementations§
source§impl Skeleton
impl Skeleton
sourcepub fn new(skeleton_data: Arc<SkeletonData>) -> Self
pub fn new(skeleton_data: Arc<SkeletonData>) -> Self
Create a new instance of the skeleton loaded in SkeletonData
.
See SkeletonJson
or SkeletonBinary
for a complete example of loading a skeleton.
sourcepub fn update_cache(&mut self)
pub fn update_cache(&mut self)
Caches information about bones and constraints. Must be called if the skin is modified or if bones, constraints, or weighted path attachments are added or removed.
sourcepub fn update_world_transform(&mut self)
pub fn update_world_transform(&mut self)
Updates the world transform for each bone and applies all constraints.
See
World transforms
in the Spine Runtimes Guide.
sourcepub unsafe fn update_world_transform_with(&mut self, parent: &Bone)
pub unsafe fn update_world_transform_with(&mut self, parent: &Bone)
Temporarily sets the root bone as a child of the specified bone, then updates the world transform for each bone and applies all constraints.
See
World transforms
in the Spine Runtimes Guide.
§Safety
The bone must originate from this skeleton.
sourcepub fn set_to_setup_pose(&mut self)
pub fn set_to_setup_pose(&mut self)
Sets the bones, constraints, slots, and draw order to their setup pose values.
sourcepub fn set_bones_to_setup_pose(&mut self)
pub fn set_bones_to_setup_pose(&mut self)
Sets the bones and constraints to their setup pose values.
sourcepub fn set_slots_to_setup_pose(&mut self)
pub fn set_slots_to_setup_pose(&mut self)
Sets the slots and draw order to their setup pose values.
sourcepub unsafe fn set_skin(&mut self, skin: &Skin)
pub unsafe fn set_skin(&mut self, skin: &Skin)
Set the skeleton’s skin. If the skin is a user-created one (via Skin::new
), then a
clone is created and used instead, to help ensure memory safety. If this behavior is not
desired then Skeleton::set_skin_unchecked
can be used instead.
§Safety
The skin must originate from the same SkeletonData
that this skeleton uses.
sourcepub unsafe fn set_skin_unchecked(&mut self, skin: &Skin)
pub unsafe fn set_skin_unchecked(&mut self, skin: &Skin)
Set the skeleton’s skin.
§Safety
The skin must originate from the same SkeletonData
that this skeleton uses.
The Skin
struct will destroy the underlying C representation of the skin in its Drop
implementation. Skins assigned to a skeleton must live as long as the skeletons using them
or else the skeleton may cause a segfault.
sourcepub unsafe fn set_skin_by_name_unchecked(&mut self, skin_name: &str)
pub unsafe fn set_skin_by_name_unchecked(&mut self, skin_name: &str)
Set the skeleton’s skin by name.
§Safety
This function should only be called with valid skin names. It is faster than the safe
alternative, Skeleton::set_skin_by_name
, but will likely segfault if the skin does not
exist.
sourcepub fn set_skin_by_name(&mut self, skin_name: &str) -> Result<(), SpineError>
pub fn set_skin_by_name(&mut self, skin_name: &str) -> Result<(), SpineError>
Set the skeleton’s skin by name.
§Errors
Returns SpineError::NotFound
if the specified skin name doesn’t exist.
sourcepub fn set_skins_by_name<'a, T>(
&mut self,
combined_skin_name: &str,
skin_names: impl IntoIterator<Item = T>
) -> Result<(), SpineError>
pub fn set_skins_by_name<'a, T>( &mut self, combined_skin_name: &str, skin_names: impl IntoIterator<Item = T> ) -> Result<(), SpineError>
Create a conglomerate skin containing skin_names
and attach to this skeleton.
skeleton.set_skins_by_name("combined-skin", ["hat", "suit", "tie"]);
The name assigned to this skin (via combined_skin_name
) is unimportant and does not need
to be unique.
A faster (but unsafe
) way to create conglomerate skins is to use Skin::new
and
Skin::add_skin
to create a pre-configured skin that can be attached at any time with
Skeleton::set_skin
.
§Errors
Returns SpineError::NotFound
if any of the specified skin names do not exist (in this
case, the current skin remains unchanged).
sourcepub fn bone_root(&self) -> CTmpRef<'_, Skeleton, Bone>
pub fn bone_root(&self) -> CTmpRef<'_, Skeleton, Bone>
The root bone, or None
if the skeleton has no bones.
sourcepub fn bone_root_mut(&mut self) -> CTmpMut<'_, Skeleton, Bone>
pub fn bone_root_mut(&mut self) -> CTmpMut<'_, Skeleton, Bone>
The mutable root bone, or None
if the skeleton has no bones.
pub fn find_bone(&self, name: &str) -> Option<CTmpRef<'_, Skeleton, Bone>>
pub fn find_bone_mut( &mut self, name: &str ) -> Option<CTmpMut<'_, Skeleton, Bone>>
pub fn find_slot(&self, name: &str) -> Option<CTmpRef<'_, Skeleton, Slot>>
pub fn find_slot_mut( &mut self, name: &str ) -> Option<CTmpMut<'_, Skeleton, Slot>>
pub fn set_attachment( &mut self, slot_name: &str, attachment_name: Option<&str> ) -> bool
pub fn get_attachment_for_slot_name( &mut self, slot_name: &str, attachment_name: &str ) -> Option<Attachment>
pub fn get_attachment_for_slot_index( &mut self, slot_index: usize, attachment_name: &str ) -> Option<Attachment>
sourcepub fn data(&self) -> CTmpRef<'_, Self, SkeletonData>
pub fn data(&self) -> CTmpRef<'_, Self, SkeletonData>
The skeleton’s setup pose data.
sourcepub fn data_mut(&mut self) -> CTmpMut<'_, Self, SkeletonData>
pub fn data_mut(&mut self) -> CTmpMut<'_, Self, SkeletonData>
The skeleton’s mutable setup pose data.
sourcepub fn color_mut(&mut self) -> &mut Color
pub fn color_mut(&mut self) -> &mut Color
Set the color to tint all the skeleton’s attachments.
sourcepub fn bones_count(&self) -> usize
pub fn bones_count(&self) -> usize
The number of bones in this skeleton.
sourcepub fn slots_count(&self) -> usize
pub fn slots_count(&self) -> usize
The number of slots in this skeleton.
sourcepub fn ik_contraints_count(&self) -> usize
pub fn ik_contraints_count(&self) -> usize
The number of IK constraints in this skeleton.
sourcepub fn transform_contraints_count(&self) -> usize
pub fn transform_contraints_count(&self) -> usize
The number of transform constraints in this skeleton.
sourcepub fn path_contraints_count(&self) -> usize
pub fn path_contraints_count(&self) -> usize
The number of path constraints in this skeleton.
sourcepub fn set_scale_x(&mut self, value: f32)
pub fn set_scale_x(&mut self, value: f32)
Sets the scale the entire skeleton on the X axis. Bones that do not inherit scale are still affected by this property.
sourcepub fn set_scale_y(&mut self, value: f32)
pub fn set_scale_y(&mut self, value: f32)
Sets the scale the entire skeleton on the Y axis. Bones that do not inherit scale are still affected by this property.
sourcepub fn x(&self) -> f32
pub fn x(&self) -> f32
The skeleton X position, which is added to the root bone worldX position.
sourcepub fn set_x(&mut self, value: f32)
pub fn set_x(&mut self, value: f32)
Sets the skeleton X position, which is added to the root bone worldX position. Bones that do not inherit translation are still affected by this property.
sourcepub fn y(&self) -> f32
pub fn y(&self) -> f32
The skeleton Y position, which is added to the root bone worldY position.
sourcepub fn set_y(&mut self, value: f32)
pub fn set_y(&mut self, value: f32)
Sets the skeleton Y position, which is added to the root bone worldY position. Bones that do not inherit translation are still affected by this property.
sourcepub fn bones(&self) -> CTmpPtrIterator<'_, Skeleton, Bone, spBone> ⓘ
pub fn bones(&self) -> CTmpPtrIterator<'_, Skeleton, Bone, spBone> ⓘ
An iterator to the skeleton’s bones.
sourcepub fn bone_at_index(&self, index: usize) -> Option<CTmpRef<'_, Self, Bone>>
pub fn bone_at_index(&self, index: usize) -> Option<CTmpRef<'_, Self, Bone>>
The nth bone in the skeleton.
sourcepub fn bones_mut(&mut self) -> CTmpMutIterator<'_, Skeleton, Bone, spBone> ⓘ
pub fn bones_mut(&mut self) -> CTmpMutIterator<'_, Skeleton, Bone, spBone> ⓘ
A mutable iterator to the skeleton’s bones.
sourcepub fn bone_at_index_mut(
&mut self,
index: usize
) -> Option<CTmpMut<'_, Self, Bone>>
pub fn bone_at_index_mut( &mut self, index: usize ) -> Option<CTmpMut<'_, Self, Bone>>
The nth mutable bone in the skeleton.
sourcepub fn slots(&self) -> CTmpPtrIterator<'_, Skeleton, Slot, spSlot> ⓘ
pub fn slots(&self) -> CTmpPtrIterator<'_, Skeleton, Slot, spSlot> ⓘ
An iterator to the skeleton’s slots.
sourcepub fn slot_at_index(&self, index: usize) -> Option<CTmpRef<'_, Self, Slot>>
pub fn slot_at_index(&self, index: usize) -> Option<CTmpRef<'_, Self, Slot>>
The nth slot in the skeleton.
sourcepub fn slots_mut(&mut self) -> CTmpMutIterator<'_, Skeleton, Slot, spSlot> ⓘ
pub fn slots_mut(&mut self) -> CTmpMutIterator<'_, Skeleton, Slot, spSlot> ⓘ
A mutable iterator to the skeleton’s slots.
sourcepub fn slot_at_index_mut(
&mut self,
index: usize
) -> Option<CTmpMut<'_, Self, Slot>>
pub fn slot_at_index_mut( &mut self, index: usize ) -> Option<CTmpMut<'_, Self, Slot>>
The nth mutable slot in the skeleton.
sourcepub fn draw_order(&self) -> CTmpPtrIterator<'_, Skeleton, Slot, spSlot> ⓘ
pub fn draw_order(&self) -> CTmpPtrIterator<'_, Skeleton, Slot, spSlot> ⓘ
An iterator to the skeleton’s slots in the order they should be drawn.
sourcepub fn draw_order_at_index(
&self,
index: usize
) -> Option<CTmpRef<'_, Self, Slot>>
pub fn draw_order_at_index( &self, index: usize ) -> Option<CTmpRef<'_, Self, Slot>>
The nth skeleton slot, indexed in the order they should be drawn.
sourcepub fn draw_order_mut(&mut self) -> CTmpMutIterator<'_, Skeleton, Slot, spSlot> ⓘ
pub fn draw_order_mut(&mut self) -> CTmpMutIterator<'_, Skeleton, Slot, spSlot> ⓘ
A mutable iterator to the skeleton’s slots in the order they should be drawn.
sourcepub fn draw_order_at_index_mut(
&mut self,
index: usize
) -> Option<CTmpMut<'_, Self, Slot>>
pub fn draw_order_at_index_mut( &mut self, index: usize ) -> Option<CTmpMut<'_, Self, Slot>>
The nth mutable skeleton slot, indexed in the order they should be drawn.
pub fn skin(&self) -> Option<CTmpRef<'_, Self, Skin>>
pub fn skin_mut(&mut self) -> Option<CTmpMut<'_, Self, Skin>>
sourcepub const fn c_ptr(&self) -> *mut spSkeleton
pub const fn c_ptr(&self) -> *mut spSkeleton
Get a pointer to the underlying spine-c
type.