Struct rusty_spine::SkeletonJson
source · pub struct SkeletonJson { /* private fields */ }
Expand description
A loader for Spine json files.
Implementations
sourceimpl SkeletonJson
impl SkeletonJson
sourcepub fn new(atlas: Arc<Atlas>) -> Self
pub fn new(atlas: Arc<Atlas>) -> Self
Create a new JSON loader using the default atlas attachment loader.
use std::sync::Arc;
use rusty_spine::{AnimationState, AnimationStateData, Atlas, SpineError, Skeleton, SkeletonJson};
fn load_skeleton() -> Result<(Skeleton, AnimationState), SpineError> {
let atlas = Arc::new(Atlas::new_from_file("spineboy.atlas")?);
let skeleton_json = SkeletonJson::new(atlas);
let skeleton_data = Arc::new(skeleton_json.read_skeleton_data_file("spineboy.json")?);
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, json: &[u8]) -> Result<SkeletonData, SpineError>
pub fn read_skeleton_data(&self, json: &[u8]) -> Result<SkeletonData, SpineError>
Read the Spine skeleton json data in-memory. See SkeletonJson::new
for a full example.
Errors
Returns SpineError::ParsingFailed
if parsing of the json 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 json data from a file. See SkeletonJson::new
for a full example.
Errors
Returns SpineError::ParsingFailed
if parsing of the json data failed. Returns
SpineError::NulError
if path
contains an internal 0 byte.
pub fn scale(&self) -> f32
pub fn set_scale(&mut self, value: f32)
pub fn c_ptr(&self) -> *mut spSkeletonJson
Trait Implementations
sourceimpl Debug for SkeletonJson
impl Debug for SkeletonJson
Auto Trait Implementations
impl RefUnwindSafe for SkeletonJson
impl Send for SkeletonJson
impl Sync for SkeletonJson
impl Unpin for SkeletonJson
impl UnwindSafe for SkeletonJson
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more