pub struct TextSprite { /* private fields */ }Expand description
This is a helper type for drawing text into a sprite. Drawing text into a sprite is the recommended way to display text when using sprites in your game; it removes timing issues and gives you the flexibility of the sprite system rather than draw_text alone.
After creation with new, you can update_text as desired, and use get_sprite or
get_sprite_mut to access the Sprite for other operations like move_to and get_bounds
(which can tell you the height and width of the generated bitmap).
Note: it’s assumed that you’re using the system font and haven’t changed its tracking; we have no way to retrieve the current font or tracking with C APIs.
Implementations§
Source§impl TextSprite
impl TextSprite
Sourcepub fn new<S>(text: S, background: LCDColor) -> Result<Self, Error>
pub fn new<S>(text: S, background: LCDColor) -> Result<Self, Error>
Creates a TextSprite, draws the given text into it over the given background color,
and adds the underlying sprite to the SpriteManager.
pub fn get_sprite(&self) -> &Sprite
pub fn get_sprite_mut(&mut self) -> &mut Sprite
Trait Implementations§
Source§impl Clone for TextSprite
impl Clone for TextSprite
Source§fn clone(&self) -> TextSprite
fn clone(&self) -> TextSprite
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more