/// ---------------------------------------------- /// dynamic example /// how to update effect behavior dynamiclly /// ---------------------------------------------- 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, change_dynamic)) .run(); } #[derive(Component)] pub struct FpsText; #[derive(Deref, Component, DerefMut)] pub struct ChangeTimer(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(( ChangeTimer(Timer::new(Duration::from_millis(300), TimerMode::Repeating)), Pcindex(0.), )); cmd.spawn((TextBundle::default(), FpsText)); cmd.spawn((ParticleSpawnerBundle { effect: server.load("base.particle.ron"), material: materials.add(SpriteParticle2dMaterial::new( server.load("enoki.png"), 1, 1, )), ..default() },)); } fn change_dynamic( mut elapsed: Local, mut query: Query<&mut ParticleEffectInstance>, time: Res