Struct rusty_spine::SkeletonBinary
source · pub struct SkeletonBinary { /* private fields */ }
Expand description
A loader for Spine binary files.
Implementations§
source§impl SkeletonBinary
impl SkeletonBinary
sourcepub fn new(atlas: Arc<Atlas>) -> Self
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))
}
sourcepub fn read_skeleton_data(
&self,
data: &[u8]
) -> Result<SkeletonData, SpineError>
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.
sourcepub fn read_skeleton_data_file<P: AsRef<Path>>(
&self,
path: P
) -> Result<SkeletonData, SpineError>
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.
sourcepub fn scale(&self) -> f32
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.
sourcepub const fn c_ptr(&self) -> *mut spSkeletonBinary
pub const fn c_ptr(&self) -> *mut spSkeletonBinary
Get a pointer to the underlying spine-c
type.