Expand description
§bevy_mod_actuate
Declarative scenes and reactivity for Bevy powered by Actuate.
use actuate::prelude::{*, Mut};
use bevy::prelude::*;
use bevy_mod_actuate::prelude::*;
#[derive(Data)]
struct Timer;
impl Compose for Timer {
fn compose(cx: Scope<Self>) -> impl Compose {
let current_time = use_mut(&cx, Time::default);
// Use the `Time` resource from the ECS world, updating the `current_time`.
use_world(&cx, move |time: Res<Time>| Mut::set(current_time, *time));
// Spawn a `Text` component, updating it when this scope is re-composed.
spawn(Text::new(format!("Elapsed: {:?}", current_time.elapsed())))
}
}
fn main() {
App::new()
.add_plugins((DefaultPlugins, ActuatePlugin))
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2d::default());
commands.spawn(Composition::new(Timer));
}
Modules§
- prelude
- Prelude of common items.
Structs§
- Actuate
Plugin - Actuate plugin to run
Composition
s. - Composition
- Composition of some composable content.
- Spawn
With - Spawn composable with content.
- UseCommands
- Hook for
use_commands
. - UseWorld
- Hook for
use_world
.
Traits§
- System
Param Function - A function that takes a
SystemParam
as input.
Functions§
- spawn
- Create a [
Spawn
] composable that spawns the providedbundle
when composed. - spawn_
with - Create a [
Spawn
] composable that spawns the providedbundle
when composed, with some content as its children. - use_
bundle - Use a spawned bundle.
- use_
commands - Use access to the current
Command
queue. - use_
world - Use a
SystemParam
from the ECS world.