Implement button::Renderer in ggez example
This commit is contained in:
parent
b4eb0df5a0
commit
ccb87b12da
5 changed files with 215 additions and 12 deletions
|
|
@ -1,14 +1,31 @@
|
|||
mod button;
|
||||
mod text;
|
||||
|
||||
use ggez::graphics::{self, Color};
|
||||
use ggez::graphics::{self, spritebatch::SpriteBatch, Color, Image};
|
||||
use ggez::Context;
|
||||
|
||||
pub struct Renderer<'a> {
|
||||
pub context: &'a mut Context,
|
||||
pub sprites: SpriteBatch,
|
||||
pub spritesheet: Image,
|
||||
}
|
||||
|
||||
impl Renderer<'_> {
|
||||
pub fn new(context: &mut Context, spritesheet: Image) -> Renderer {
|
||||
Renderer {
|
||||
context,
|
||||
sprites: SpriteBatch::new(spritesheet.clone()),
|
||||
spritesheet,
|
||||
}
|
||||
}
|
||||
pub fn flush(&mut self) {
|
||||
graphics::draw(
|
||||
self.context,
|
||||
&self.sprites,
|
||||
graphics::DrawParam::default(),
|
||||
)
|
||||
.expect("Draw sprites");
|
||||
|
||||
graphics::draw_queued_text(
|
||||
self.context,
|
||||
graphics::DrawParam::default(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue