pub struct Sprite {Show 14 fields
pub name: String,
pub variables: HashMap<String, Variable>,
pub lists: HashMap<String, List>,
pub scripts: Vec<Script>,
pub current_costume: usize,
pub sounds: HashMap<String, Sound>,
pub volume: f32,
pub layer_order: isize,
pub visible: bool,
pub position: (i32, i32),
pub size: f32,
pub direction: i32,
pub draggable: bool,
pub rotation_style: RotationStyle,
/* private fields */
}Expand description
The Sprite struct represents a sprite in a Scratch 3.0 project.
Fields§
§name: StringThe name of the sprite.
variables: HashMap<String, Variable>Contains all the variables of the sprite.
lists: HashMap<String, List>Contains all the lists of the sprite.
scripts: Vec<Script>Contains all the scripts of the sprite.
current_costume: usizeThe index of the current costume.
sounds: HashMap<String, Sound>Contains all the sounds of the sprite.
volume: f32The sprite’s volume (0.0 = 0%, 1.0 = 100%)
layer_order: isizeThe layer of the sprite.
visible: boolIf the sprite is visible.
position: (i32, i32)The position of the sprite.
size: f32The size of the sprite (0.0 = 0%, 1.0 = 100%)
direction: i32The direction of the sprite in degrees.
draggable: boolIf the sprite is draggable.
rotation_style: RotationStyleThe rotation style of the sprite.
Implementations§
Source§impl Sprite
impl Sprite
Sourcepub fn new(
raw: RawSprite,
zip: &mut ZipArchive<Cursor<Vec<u8>>>,
) -> Result<Self, DecodeError>
pub fn new( raw: RawSprite, zip: &mut ZipArchive<Cursor<Vec<u8>>>, ) -> Result<Self, DecodeError>
Returns a new sprite from a RawSprite and the zip archive.
Sourcepub fn get_costume(&self, name: &str) -> Option<&Costume>
pub fn get_costume(&self, name: &str) -> Option<&Costume>
Returns a reference to a costume by its name, if it exists.
Sourcepub fn get_costume_mut(&mut self, name: &str) -> Option<&mut Costume>
pub fn get_costume_mut(&mut self, name: &str) -> Option<&mut Costume>
Returns a mutable reference to a costume by its name, if it exists.
Sourcepub fn costume_names(&self) -> Vec<&String>
pub fn costume_names(&self) -> Vec<&String>
Returns all the costume names in the sprite.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sprite
impl RefUnwindSafe for Sprite
impl Send for Sprite
impl Sync for Sprite
impl Unpin for Sprite
impl UnwindSafe for Sprite
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more