Mount examples/resources in ggez::filesystem
This commit is contained in:
parent
d59d3f033d
commit
55a74a09ce
3 changed files with 23 additions and 16 deletions
|
|
@ -8,20 +8,33 @@ use widget::Column;
|
|||
|
||||
use ggez;
|
||||
use ggez::event;
|
||||
use ggez::filesystem;
|
||||
use ggez::graphics;
|
||||
use ggez::input::mouse;
|
||||
|
||||
pub fn main() -> ggez::GameResult {
|
||||
let cb = ggez::ContextBuilder::new("iced", "ggez").window_mode(
|
||||
ggez::conf::WindowMode {
|
||||
width: 1280.0,
|
||||
height: 1024.0,
|
||||
..ggez::conf::WindowMode::default()
|
||||
},
|
||||
let (context, event_loop) = {
|
||||
&mut ggez::ContextBuilder::new("iced", "ggez")
|
||||
.window_mode(ggez::conf::WindowMode {
|
||||
width: 1280.0,
|
||||
height: 1024.0,
|
||||
..ggez::conf::WindowMode::default()
|
||||
})
|
||||
.build()?
|
||||
};
|
||||
|
||||
filesystem::mount(
|
||||
context,
|
||||
std::path::Path::new(&format!(
|
||||
"{}/examples/resources",
|
||||
env!("CARGO_MANIFEST_DIR")
|
||||
)),
|
||||
true,
|
||||
);
|
||||
let (ctx, event_loop) = &mut cb.build()?;
|
||||
let state = &mut Game::new(ctx)?;
|
||||
event::run(ctx, event_loop, state)
|
||||
|
||||
let state = &mut Game::new(context)?;
|
||||
|
||||
event::run(context, event_loop, state)
|
||||
}
|
||||
|
||||
struct Game {
|
||||
|
|
@ -115,8 +128,6 @@ impl event::EventHandler for Game {
|
|||
fn draw(&mut self, context: &mut ggez::Context) -> ggez::GameResult {
|
||||
graphics::clear(context, [0.3, 0.3, 0.6, 1.0].into());
|
||||
|
||||
self.tour.draw(context).expect("Draw tour");
|
||||
|
||||
let screen = graphics::screen_coordinates(context);
|
||||
|
||||
let (messages, cursor) = {
|
||||
|
|
|
|||
|
|
@ -43,5 +43,5 @@ impl Renderer<'_> {
|
|||
impl iced::Renderer for Renderer<'_> {
|
||||
type Color = Color;
|
||||
|
||||
fn explain(&mut self, layout: &iced::Layout<'_>, color: Color) {}
|
||||
fn explain(&mut self, _layout: &iced::Layout<'_>, _color: Color) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,6 @@ impl Tour {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn draw(&mut self, context: &mut ggez::Context) -> ggez::GameResult {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn react(&mut self, event: Message) {
|
||||
match event {
|
||||
Message::BackPressed => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue