/// ---------------------------------------------- /// sprite example /// how to display a sprite animation/texture /// ---------------------------------------------- use bevy::{core_pipeline::bloom::BloomSettings, diagnostic::DiagnosticsStore, prelude::*}; use bevy_enoki::{prelude::*, EnokiPlugin}; use std::time::Duration; fn main() { App::new() .add_plugins(DefaultPlugins.set(ImagePlugin { default_sampler: bevy::render::texture::ImageSamplerDescriptor::nearest(), })) .add_plugins(bevy::diagnostic::FrameTimeDiagnosticsPlugin) .add_plugins(EnokiPlugin) .add_systems(Startup, setup) .add_systems(Update, (show_fps, spawn_particles)) .run(); } #[derive(Component)] pub struct FpsText; #[derive(Deref, Component, DerefMut)] pub struct MoveTimer(Timer); #[derive(Deref, Component, DerefMut)] pub struct Pcindex(f32); #[derive(Deref, Resource, DerefMut)] pub struct ParticleMaterialAsset(Handle); fn setup( mut cmd: Commands, mut materials: ResMut>, server: Res, ) { cmd.spawn(( Camera2dBundle { camera: Camera { clear_color: ClearColorConfig::Custom(Color::BLACK), hdr: true, ..default() }, ..default() }, BloomSettings { intensity: 0.1, ..default() }, )); cmd.spawn(( MoveTimer(Timer::new(Duration::from_millis(300), TimerMode::Repeating)), Pcindex(0.), )); cmd.spawn((TextBundle::default(), FpsText)); cmd.insert_resource(ParticleMaterialAsset(materials.add( SpriteParticle2dMaterial::new(server.load("particle.png"), 6, 1), ))); } fn spawn_particles( mut cmd: Commands, mut query: Query<(&mut MoveTimer, &mut Pcindex)>, time: Res