Add player sprite
This commit is contained in:
parent
4ab62ea921
commit
04fe103b25
@ -18,5 +18,6 @@ fn main() {
|
||||
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_startup_system(setup.system())
|
||||
.add_startup_system(add_player.system())
|
||||
.run();
|
||||
}
|
||||
|
@ -31,11 +31,23 @@ pub fn setup(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_player(mut commands: Commands) {
|
||||
pub fn add_player(
|
||||
mut commands: Commands,
|
||||
asset_server: Res<AssetServer>,
|
||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||
) {
|
||||
let player_sprite = materials.add(asset_server.load("marshmallow.png").into());
|
||||
|
||||
commands
|
||||
.spawn()
|
||||
.insert(Player)
|
||||
.insert(Name("Player 1".to_string()));
|
||||
.insert(Name("Player 1".to_string()))
|
||||
.insert_bundle(SpriteBundle {
|
||||
material: player_sprite,
|
||||
sprite: Sprite::new(Vec2::new(64.0, 64.0)),
|
||||
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
pub fn greet_player(
|
||||
|
Loading…
x
Reference in New Issue
Block a user