INNER CODE UNIT · Rust

add_sprite

CleanCut/rusty_engine · src/game.rs:115

    pub fn add_sprite<T: Into<String>, P: Into<PathBuf>>(
        &mut self,
        label: T,
        file_or_preset: P,
    ) -> &mut Sprite {
        let label = label.into();
        self.sprites
            .insert(label.clone(), Sprite::new(label.clone(), file_or_preset));
        // Unwrap: Can't crash because we just inserted the sprite
        self.sprites.get_mut(&label).unwrap()
    }

    #[must_use]
    /// Create and add a [`Text`] to the game. Use the `&mut Text` that is returned to adjust the
    /// translation, rotation, etc. Use a *unique* label for each text. Attempting to add two texts
    /// with the same label will cause a crash.
    pub fn add_text<T, S>(&mut self, label: T, text: S) -> &mut Text
    where

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…