bevy/examples/2d/sprite.rs

29 lines
755 B
Rust
Raw Normal View History

2020-05-04 08:22:25 +00:00
use bevy::prelude::*;
fn main() {
App::build()
.add_default_plugins()
2020-05-14 00:31:56 +00:00
.add_startup_system(setup.system())
2020-05-04 08:22:25 +00:00
.run();
}
2020-05-14 00:31:56 +00:00
fn setup(
command_buffer: &mut CommandBuffer,
2020-05-16 02:30:02 +00:00
asset_server: Res<AssetServer>,
2020-05-14 00:52:47 +00:00
mut materials: ResMut<Assets<ColorMaterial>>,
2020-05-14 00:31:56 +00:00
) {
2020-05-16 02:30:02 +00:00
let texture_handle = asset_server.load("assets/branding/icon.png").unwrap();
2020-05-14 00:31:56 +00:00
command_buffer
2020-05-04 08:22:25 +00:00
.build()
.add_entity(OrthographicCameraEntity::ui())
2020-05-04 08:22:25 +00:00
.add_entity(SpriteEntity {
rect: Rect {
position: Vec2::new(300.0, 300.0),
z_index: 0.5,
..Default::default()
},
2020-05-14 00:31:56 +00:00
material: materials.add(texture_handle.into()),
2020-05-04 08:22:25 +00:00
..Default::default()
});
}