pub struct SkeletonJson { /* private fields */ }
Expand description

A loader for Spine json files.

Spine API Reference

Implementations

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

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.

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.

Trait Implementations

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.