Latest commit b724a0f
use bevy::{app::ScheduleRunnerSettings, prelude::*, utils::Duration}; // 这个例子只启用了 bevy 运行所需的一组最低限度的插件 // 也可以从 bevy 中完全删除渲染/窗口插件,只需在 Cargo.toml 中设置成这样: // // [dependencies] // bevy = { version = "*", default-features = false } /// 不添加默认插件的应用程序 fn main() { // 这个 App 只运行一次 App::new() .insert_resource(ScheduleRunnerSettings::run_once()) .add_plugins(MinimalPlugins) .add_system(你好世界) .run(); // 这个App每秒运行 60 次(60 fps) App::new() .insert_resource(ScheduleRunnerSettings::run_loop(Duration::from_scs_f64( 1.0 / 60.0, ))) .add_plugins(MinimalPlugins) .add_system(计数器) .run() } fn 你好世界() { println!("hello world"); } #[derive(Default)] struct CounterState { count: u32, } fn 计数器(mut state: Local<CounterState>) { if state.count % 60 == 0 { println!("{}", state.count); } state.count += 1; }