generated from 2ndbeam/bevy-template
feat: Implemented layout assets resource
- Layout sprites are now looking as before
This commit is contained in:
parent
b2efc73602
commit
c1f9c29fe7
9 changed files with 131 additions and 72 deletions
|
|
@ -10,8 +10,6 @@ use crate::{
|
|||
|
||||
use super::*;
|
||||
|
||||
const PADLOCK_IMAGE_PATH: &'static str = "sprites/interactive/padlock.png";
|
||||
|
||||
#[derive(Component, Debug, PartialEq, Eq, Default, Clone, Copy, Reflect)]
|
||||
#[reflect(Component, Debug, PartialEq, Default, Clone)]
|
||||
#[require(InteractiveObject)]
|
||||
|
|
@ -51,21 +49,29 @@ pub fn on_padlock_interaction(
|
|||
commands.entity(lockpick_id).despawn();
|
||||
}
|
||||
|
||||
pub fn padlock_bundle(asset_server: &Res<AssetServer>, facing_left: bool) -> impl Bundle {
|
||||
let image = asset_server.load(PADLOCK_IMAGE_PATH);
|
||||
pub fn padlock_bundle(textures: &Res<LayoutTextures>, facing_left: bool) -> impl Bundle {
|
||||
let sign = if facing_left { -1. } else { 1. };
|
||||
(
|
||||
Padlock,
|
||||
Sprite {
|
||||
image,
|
||||
flip_x: facing_left,
|
||||
..default()
|
||||
flip_x: !facing_left,
|
||||
..textures.lock.sprite("main")
|
||||
},
|
||||
Transform::from_xyz(meters(sign * 0.125), meters(0.), 0.),
|
||||
Children::spawn_one((
|
||||
Transform::from_xyz(meters(sign * 0.1875), 0., 0.),
|
||||
Collider::cuboid(meters(0.1875), meters(1.)),
|
||||
Sensor,
|
||||
InheritedVisibility::VISIBLE,
|
||||
Children::spawn((
|
||||
Spawn((
|
||||
Transform::from_xyz(meters(sign * 0.1875), 0., 0.),
|
||||
Collider::cuboid(meters(0.1875), meters(1.)),
|
||||
Sensor,
|
||||
)),
|
||||
Spawn((
|
||||
Sprite {
|
||||
flip_x: !facing_left,
|
||||
..textures.lock.sprite("highlight")
|
||||
},
|
||||
Visibility::Hidden,
|
||||
)),
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue