bevy-playground/src/statue.rs

41 lines
1.1 KiB
Rust
Raw Normal View History

use bevy::prelude::*;
use crate::assets::AssetLoader;
#[derive(Component, Debug)]
pub struct Statue;
impl Plugin for Statue {
fn build(&self, app: &mut App) {
app.add_systems(PostStartup, spawn_statue);
}
}
2024-05-17 09:57:24 -05:00
fn spawn_statue(mut commands: Commands, assets: Res<AssetLoader>, asset_server: Res<AssetServer>) {
let texture = asset_server.load("img/Props.png");
commands.spawn((
Statue,
SpriteSheetBundle {
2024-05-17 09:57:24 -05:00
texture: texture.clone(),
atlas: TextureAtlas {
layout: assets.images.statue.clone(),
index: 0,
},
transform: Transform::from_translation(Vec3::new(50., 50., 0.)),
..Default::default()
},
));
commands.spawn((
Statue,
SpriteSheetBundle {
2024-05-17 09:57:24 -05:00
texture: texture.clone(),
atlas: TextureAtlas {
layout: assets.images.statue.clone(),
index: 0,
},
transform: Transform::from_translation(Vec3::new(50., 100., 0.)),
..Default::default()
},
));
}