Struct crankstart::sprite::TextSprite
source · 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>where
S: AsRef<str>,
pub fn new<S>(text: S, background: LCDColor) -> Result<Self, Error>where S: AsRef<str>,
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