Add sprite flipping to testbed_2d
's sprite scene (#18537)
# Objective Add sprite flipping to `testbed_2d`'s sprite scene ## Solution Draw the sprite flipped in each axis and both axes. Changed the sprite to the rectangular bevy banner with text and made the images different colors. ## Testing ``` cargo run --example testbed_2d ```  --------- Co-authored-by: François Mockers <mockersf@gmail.com>
This commit is contained in:
parent
921ff6701f
commit
f74abb1b89
@ -258,14 +258,30 @@ mod text {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod sprite {
|
mod sprite {
|
||||||
|
use bevy::color::palettes::css::{BLUE, LIME, RED};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use bevy::sprite::Anchor;
|
||||||
|
|
||||||
pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn((Camera2d, StateScoped(super::Scene::Sprite)));
|
commands.spawn((Camera2d, StateScoped(super::Scene::Sprite)));
|
||||||
commands.spawn((
|
for (anchor, flip_x, flip_y, color) in [
|
||||||
Sprite::from_image(asset_server.load("branding/bevy_bird_dark.png")),
|
(Anchor::BOTTOM_LEFT, false, false, Color::WHITE),
|
||||||
StateScoped(super::Scene::Sprite),
|
(Anchor::BOTTOM_RIGHT, true, false, RED.into()),
|
||||||
));
|
(Anchor::TOP_LEFT, false, true, LIME.into()),
|
||||||
|
(Anchor::TOP_RIGHT, true, true, BLUE.into()),
|
||||||
|
] {
|
||||||
|
commands.spawn((
|
||||||
|
Sprite {
|
||||||
|
image: asset_server.load("branding/bevy_logo_dark.png"),
|
||||||
|
anchor,
|
||||||
|
flip_x,
|
||||||
|
flip_y,
|
||||||
|
color,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
StateScoped(super::Scene::Sprite),
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user