Struct rusty_spine::Skeleton

source ·
pub struct Skeleton { /* private fields */ }
Expand description

A live Skeleton instance created from SkeletonData.

Spine API Reference

Implementations§

source§

impl Skeleton

source

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.

source

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.

source

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.

source

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.

source

pub fn set_to_setup_pose(&mut self)

Sets the bones, constraints, slots, and draw order to their setup pose values.

source

pub fn set_bones_to_setup_pose(&mut self)

Sets the bones and constraints to their setup pose values.

source

pub fn set_slots_to_setup_pose(&mut self)

Sets the slots and draw order to their setup pose values.

source

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.

source

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.

source

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.

source

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.

source

pub fn set_skins_by_name<'a, T>( &mut self, combined_skin_name: &str, skin_names: impl IntoIterator<Item = T> ) -> Result<(), SpineError>
where Cow<'a, str>: From<T>,

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).

source

pub fn bone_root(&self) -> CTmpRef<'_, Skeleton, Bone>

The root bone, or None if the skeleton has no bones.

source

pub fn bone_root_mut(&mut self) -> CTmpMut<'_, Skeleton, Bone>

The mutable root bone, or None if the skeleton has no bones.

source

pub fn find_bone(&self, name: &str) -> Option<CTmpRef<'_, Skeleton, Bone>>

source

pub fn find_bone_mut( &mut self, name: &str ) -> Option<CTmpMut<'_, Skeleton, Bone>>

source

pub fn find_slot(&self, name: &str) -> Option<CTmpRef<'_, Skeleton, Slot>>

source

pub fn find_slot_mut( &mut self, name: &str ) -> Option<CTmpMut<'_, Skeleton, Slot>>

source

pub fn set_attachment( &mut self, slot_name: &str, attachment_name: Option<&str> ) -> bool

source

pub fn get_attachment_for_slot_name( &mut self, slot_name: &str, attachment_name: &str ) -> Option<Attachment>

source

pub fn get_attachment_for_slot_index( &mut self, slot_index: usize, attachment_name: &str ) -> Option<Attachment>

source

pub fn data(&self) -> CTmpRef<'_, Self, SkeletonData>

The skeleton’s setup pose data.

source

pub fn data_mut(&mut self) -> CTmpMut<'_, Self, SkeletonData>

The skeleton’s mutable setup pose data.

source

pub fn color(&self) -> Color

The color to tint all the skeleton’s attachments.

source

pub fn color_mut(&mut self) -> &mut Color

Set the color to tint all the skeleton’s attachments.

source

pub fn bones_count(&self) -> usize

The number of bones in this skeleton.

source

pub fn slots_count(&self) -> usize

The number of slots in this skeleton.

source

pub fn ik_contraints_count(&self) -> usize

The number of IK constraints in this skeleton.

source

pub fn transform_contraints_count(&self) -> usize

The number of transform constraints in this skeleton.

source

pub fn path_contraints_count(&self) -> usize

The number of path constraints in this skeleton.

source

pub fn scale_x(&self) -> f32

Scales the entire skeleton on the X axis.

source

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.

source

pub fn scale_y(&self) -> f32

Scales the entire skeleton on the Y axis.

source

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.

source

pub fn x(&self) -> f32

The skeleton X position, which is added to the root bone worldX position.

source

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.

source

pub fn y(&self) -> f32

The skeleton Y position, which is added to the root bone worldY position.

source

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.

source

pub fn bones(&self) -> CTmpPtrIterator<'_, Skeleton, Bone, spBone>

An iterator to the skeleton’s bones.

source

pub fn bone_at_index(&self, index: usize) -> Option<CTmpRef<'_, Self, Bone>>

The nth bone in the skeleton.

source

pub fn bones_mut(&mut self) -> CTmpMutIterator<'_, Skeleton, Bone, spBone>

A mutable iterator to the skeleton’s bones.

source

pub fn bone_at_index_mut( &mut self, index: usize ) -> Option<CTmpMut<'_, Self, Bone>>

The nth mutable bone in the skeleton.

source

pub fn slots(&self) -> CTmpPtrIterator<'_, Skeleton, Slot, spSlot>

An iterator to the skeleton’s slots.

source

pub fn slot_at_index(&self, index: usize) -> Option<CTmpRef<'_, Self, Slot>>

The nth slot in the skeleton.

source

pub fn slots_mut(&mut self) -> CTmpMutIterator<'_, Skeleton, Slot, spSlot>

A mutable iterator to the skeleton’s slots.

source

pub fn slot_at_index_mut( &mut self, index: usize ) -> Option<CTmpMut<'_, Self, Slot>>

The nth mutable slot in the skeleton.

source

pub fn draw_order(&self) -> CTmpPtrIterator<'_, Skeleton, Slot, spSlot>

An iterator to the skeleton’s slots in the order they should be drawn.

source

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.

source

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.

source

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.

source

pub fn skin(&self) -> Option<CTmpRef<'_, Self, Skin>>

source

pub fn skin_mut(&mut self) -> Option<CTmpMut<'_, Self, Skin>>

source

pub const fn c_ptr(&self) -> *mut spSkeleton

Get a pointer to the underlying spine-c type.

source§

impl Skeleton

Functions available if using the mint feature.

source

pub fn position(&self) -> Vector2<f32>

source

pub fn set_position(&mut self, position: impl Into<Vector2<f32>>)

source

pub fn scale(&self) -> Vector2<f32>

source

pub fn set_scale(&mut self, scale: impl Into<Vector2<f32>>)

Trait Implementations§

source§

impl Debug for Skeleton

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Skeleton

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.