一键导入
bevy-timers
Reference for Bevy timers — Timer as resource, component, or Local; tick, finished/just_finished, TimerMode::Once vs Repeat.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Reference for Bevy timers — Timer as resource, component, or Local; tick, finished/just_finished, TimerMode::Once vs Repeat.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | bevy-timers |
| description | Reference for Bevy timers — Timer as resource, component, or Local; tick, finished/just_finished, TimerMode::Once vs Repeat. |
| metadata | {"crate":"bevy_time","bevy":"0.19"} |
TimerMode::Once — ticks to 0 once, resets manuallyTimerMode::Repeat — auto-resets when finishedTimers tick up from zero to their Duration.
#[derive(Resource)]
struct MatchTime(Timer);
impl Default for MatchTime {
fn default() -> Self { Self(Timer::from_seconds(60.0, TimerMode::Once)) }
}
fn countdown(time: Res<Time>, mut match_time: ResMut<MatchTime>) {
match_time.0.tick(time.delta());
}
fn end_match(match_time: Res<MatchTime>) {
if match_time.0.finished() { /* game over */ }
}
#[derive(Component)]
struct Cooldown(Timer);
fn tick_cooldowns(mut commands: Commands, mut cooldowns: Query<(Entity, &mut Cooldown)>, time: Res<Time>) {
for (entity, mut cd) in &mut cooldowns {
cd.0.tick(time.delta());
if cd.0.finished() {
commands.entity(entity).remove::<Cooldown>();
}
}
}
fn local_timer(time: Res<Time>, mut timer: Local<Timer>) {
timer.tick(time.delta());
if timer.just_finished() {
info!("Timer finished");
}
}
| Method | Description |
|---|---|
tick(delta) | Advance the timer |
finished() | True if timer has reached duration |
just_finished() | True if finished on the last tick |
fraction() | Progress as f32 (0.0 to 1.0) |
reset() | Reset to zero |
duration() / set_duration() | Get/set duration |
fn time_info(time: Res<Time>) {
info!("delta: {:?}", time.delta());
info!("elapsed: {:?}", time.elapsed());
}
Reference for Avian physics engine — rigid bodies, colliders, joints, spatial queries, collision events, character controllers, and debug rendering.
Reference for loading, managing, and tracking assets in Bevy — AssetServer, handles, loading states, events, custom loaders, and hot reloading.
Reference for playing and controlling audio in Bevy — AudioPlayer, AudioSink, spatial audio, volume, and playback settings.
Reference for Bevy Scene Notation (BSN) — the bsn! macro for defining inline scenes with components, children, relationships, observers, and dynamic props.
Reference for cameras in Bevy — Camera2d, Camera3d, viewports, projection, render layers, mouse-to-world, and free camera controllers.
Reference for Bevy Commands — spawning/despawning entities, inserting/removing components, custom commands, trait extensions, and testing.