Struct rusty_spine::SkeletonBinary

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

A loader for Spine binary files.

Spine API Reference

Implementations§

source§

impl SkeletonBinary

source

pub fn new(atlas: Arc<Atlas>) -> Self

Create a new Binary loader using the default atlas attachment loader.

use std::sync::Arc;
use rusty_spine::{AnimationState, AnimationStateData, Atlas, SpineError, Skeleton, SkeletonBinary};

fn load_skeleton() -> Result<(Skeleton, AnimationState), SpineError> {
    let atlas = Arc::new(Atlas::new_from_file("spineboy.atlas")?);
    let skeleton_binary = SkeletonBinary::new(atlas);
    let skeleton_data = Arc::new(skeleton_binary.read_skeleton_data_file("spineboy.skel")?);
    let animation_state_data = AnimationStateData::new(skeleton_data.clone());
    // ... prepare animation state (see AnimationStateData docs) ...
    let skeleton = Skeleton::new(skeleton_data);
    let animation_state = AnimationState::new(Arc::new(animation_state_data));
    Ok((skeleton, animation_state))
}
source

pub fn read_skeleton_data( &self, data: &[u8] ) -> Result<SkeletonData, SpineError>

Read the Spine skeleton binary data in-memory. See SkeletonBinary::new for a full example.

§Errors

Returns SpineError::ParsingFailed if parsing of the binary data failed.

source

pub fn read_skeleton_data_file<P: AsRef<Path>>( &self, path: P ) -> Result<SkeletonData, SpineError>

Read the Spine skeleton binary data from a file. See SkeletonBinary::new for a full example.

§Errors

Returns SpineError::ParsingFailed if parsing of the binary data failed. Returns SpineError::NulError if path contains an internal 0 byte. Returns SpineError::PathNotUtf8 if the specified path is not utf-8.

source

pub fn scale(&self) -> f32

Scales bone positions, image sizes, and translations as they are loaded. This allows different size images to be used at runtime than were used in Spine.

See Scaling in the Spine Runtimes Guide.

source

pub fn set_scale(&mut self, value: f32)

Sets the scaling of this skeleton, see scale.

source

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

Get a pointer to the underlying spine-c type.

Trait Implementations§

source§

impl Debug for SkeletonBinary

source§

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

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

impl Drop for SkeletonBinary

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.