# Objective Make the examples look more uniform and more polished. following the issue #17167 ## Solution - [x] Added a minimal UI explaining how to interact with the examples only when needed. - [x] Used the same notation for interactions ex : "Up Arrow: Move Forward \nLeft / Right Arrow: Turn" - [x] Set the color to [GRAY](https://github.com/bevyengine/bevy/pull/17237#discussion_r1907560092) when it's not visible enough - [x] Changed some colors to be easy on the eyes - [x] removed the //camera comment - [x] Unified the use of capital letters in the examples. - [x] Simplified the mesh2d_arc offset calculations. ... --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Rob Parrett <robparrett@gmail.com>
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
//! Displays a single [`Sprite`] tiled in a grid, with a scaling animation
 | 
						|
 | 
						|
use bevy::prelude::*;
 | 
						|
 | 
						|
fn main() {
 | 
						|
    App::new()
 | 
						|
        .add_plugins(DefaultPlugins)
 | 
						|
        .add_systems(Startup, setup)
 | 
						|
        .add_systems(Update, animate)
 | 
						|
        .run();
 | 
						|
}
 | 
						|
 | 
						|
#[derive(Resource)]
 | 
						|
struct AnimationState {
 | 
						|
    min: f32,
 | 
						|
    max: f32,
 | 
						|
    current: f32,
 | 
						|
    speed: f32,
 | 
						|
}
 | 
						|
 | 
						|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
 | 
						|
    commands.spawn(Camera2d);
 | 
						|
 | 
						|
    commands.insert_resource(AnimationState {
 | 
						|
        min: 128.0,
 | 
						|
        max: 512.0,
 | 
						|
        current: 128.0,
 | 
						|
        speed: 50.0,
 | 
						|
    });
 | 
						|
    commands.spawn(Sprite {
 | 
						|
        image: asset_server.load("branding/icon.png"),
 | 
						|
        image_mode: SpriteImageMode::Tiled {
 | 
						|
            tile_x: true,
 | 
						|
            tile_y: true,
 | 
						|
            stretch_value: 0.5, // The image will tile every 128px
 | 
						|
        },
 | 
						|
        ..default()
 | 
						|
    });
 | 
						|
}
 | 
						|
 | 
						|
fn animate(mut sprites: Query<&mut Sprite>, mut state: ResMut<AnimationState>, time: Res<Time>) {
 | 
						|
    if state.current >= state.max || state.current <= state.min {
 | 
						|
        state.speed = -state.speed;
 | 
						|
    };
 | 
						|
    state.current += state.speed * time.delta_secs();
 | 
						|
    for mut sprite in &mut sprites {
 | 
						|
        sprite.custom_size = Some(Vec2::splat(state.current));
 | 
						|
    }
 | 
						|
}
 |