Compare commits
2 commits
47972f0f6c
...
1031e06024
| Author | SHA1 | Date | |
|---|---|---|---|
| 1031e06024 | |||
| c609a7d602 |
2 changed files with 40 additions and 10 deletions
|
|
@ -3,6 +3,14 @@ use bevy::prelude::*;
|
||||||
|
|
||||||
pub mod hand;
|
pub mod hand;
|
||||||
|
|
||||||
|
pub struct CardsPlugin;
|
||||||
|
|
||||||
|
impl Plugin for CardsPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app.add_observer(on_create_card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Card;
|
pub struct Card;
|
||||||
|
|
||||||
|
|
@ -17,13 +25,34 @@ pub fn on_create_card(
|
||||||
atlas_layout: Res<LofparaAtlasLayout>,
|
atlas_layout: Res<LofparaAtlasLayout>,
|
||||||
atlas_sprite: Res<LofparaAtlasImage>,
|
atlas_sprite: Res<LofparaAtlasImage>,
|
||||||
) {
|
) {
|
||||||
commands.spawn((
|
if let Some(parent) = event.parent {
|
||||||
Card,
|
commands.spawn((
|
||||||
Transform::from_xyz(0., 0., 0.),
|
Card,
|
||||||
/*Sprite {
|
Transform::from_xyz(0., 0., 0.),
|
||||||
image: atlas_sprite.get(),
|
Sprite {
|
||||||
image_mode: SpriteImageMode::Auto,
|
image: atlas_sprite.get(),
|
||||||
texture_atlas: Some(TextureAtlas { layout: , index: () })
|
image_mode: SpriteImageMode::Auto,
|
||||||
},*/
|
texture_atlas: Some(TextureAtlas {
|
||||||
));
|
layout: atlas_layout.get(),
|
||||||
|
index: 0,
|
||||||
|
}),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
ChildOf(parent),
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
commands.spawn((
|
||||||
|
Card,
|
||||||
|
Transform::from_xyz(0., 0., 0.),
|
||||||
|
Sprite {
|
||||||
|
image: atlas_sprite.get(),
|
||||||
|
image_mode: SpriteImageMode::Auto,
|
||||||
|
texture_atlas: Some(TextureAtlas {
|
||||||
|
layout: atlas_layout.get(),
|
||||||
|
index: 0,
|
||||||
|
}),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
use crate::cards::CardsPlugin;
|
||||||
use crate::lofpara_atlas::LofparaAtlasPlugin;
|
use crate::lofpara_atlas::LofparaAtlasPlugin;
|
||||||
|
|
||||||
mod cards;
|
mod cards;
|
||||||
mod lofpara_atlas;
|
mod lofpara_atlas;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new().add_plugins((DefaultPlugins, LofparaAtlasPlugin));
|
App::new().add_plugins((DefaultPlugins, LofparaAtlasPlugin, CardsPlugin));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue