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
```


![image](https://github.com/user-attachments/assets/dcfe687b-2f40-4417-bb20-6c892b425228)

---------

Co-authored-by: François Mockers <mockersf@gmail.com>
This commit is contained in:
ickshonpe 2025-03-25 21:14:17 +00:00 committed by GitHub
parent 921ff6701f
commit f74abb1b89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -258,14 +258,30 @@ mod text {
}
mod sprite {
use bevy::color::palettes::css::{BLUE, LIME, RED};
use bevy::prelude::*;
use bevy::sprite::Anchor;
pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn((Camera2d, StateScoped(super::Scene::Sprite)));
commands.spawn((
Sprite::from_image(asset_server.load("branding/bevy_bird_dark.png")),
StateScoped(super::Scene::Sprite),
));
for (anchor, flip_x, flip_y, color) in [
(Anchor::BOTTOM_LEFT, false, false, Color::WHITE),
(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),
));
}
}
}