Joystick sprite done

Development
Johannes Hendrik Gerard van der Weide 2024-01-11 19:35:22 +01:00
parent 16ac1444ce
commit d1d0eac44d
4 changed files with 27 additions and 5 deletions

BIN
assets/circle_empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

BIN
assets/circle_full.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

View File

@ -4,7 +4,8 @@
down: S down: S
left: A left: A
right: D right: D
input_sprite_path: neocat.png input_lower_sprite_path: circle_empty.png
input_upper_sprite_path: circle_full.png
input_sprite_size: [ input_sprite_size: [
30.0, 30.0,
30.0 30.0

View File

@ -12,7 +12,8 @@ pub struct Settings {
pub down: String, pub down: String,
pub left: String, pub left: String,
pub right: String, pub right: String,
pub input_sprite_path: String, pub input_lower_sprite_path: String,
pub input_upper_sprite_path: String,
pub input_sprite_size: Vec2, pub input_sprite_size: Vec2,
pub input_sprite_location: Vec2, pub input_sprite_location: Vec2,
} }
@ -60,7 +61,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
down: S down: S
left: A left: A
right: D right: D
input_sprite_path: neocat.png input_lower_sprite_path: circle_empty.png
input_upper_sprite_path: circle_full.png
input_sprite_size: [ input_sprite_size: [
30.0, 30.0,
30.0 30.0
@ -76,7 +78,26 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let settings_data = let settings_data =
serde_yaml::from_str::<Settings>(&settings_yaml[0]).expect("Error serializing to YAML"); serde_yaml::from_str::<Settings>(&settings_yaml[0]).expect("Error serializing to YAML");
commands.spawn(
SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(
settings_data.input_sprite_size.x,
settings_data.input_sprite_size.y,
)),
anchor:
bevy::sprite::Anchor::Custom(Vec2::new(
6.658,
6.658,
)),
..default()
},
texture: asset_server.load(settings_data.input_lower_sprite_path),
..default()
}
);
commands.spawn(( commands.spawn((
SpriteBundle { SpriteBundle {
sprite: Sprite { sprite: Sprite {
@ -86,7 +107,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
)), )),
..default() ..default()
}, },
texture: asset_server.load(settings_data.input_sprite_path), texture: asset_server.load(settings_data.input_upper_sprite_path),
..default() ..default()
}, },
InputVisual { InputVisual {