Bevy 引擎还处于一个非常早期的阶段,本文的内容很容易过时。若有商业开发需求 Godot 会更为合适。代码基于bevy v0.11.2
默认已通过 rustup 安装 rust 环境
$ cargo new hello-ecs
$ cd hello-ecs
$ cargo add bevy-ecs
$ code .
打开 src/main.rs
粘贴上下面的代码
use bevy_ecs::prelude::*;
fn main() {
let mut world = World::new();
let mut schedule = Schedule::default();
schedule.add_systems(hello_system);
schedule.run(&mut world);
}
fn hello_system() {
println!("Hello, ECS!");
}
回到终端:
$ cargo run
终端显示:
Hello, ECS!
恭喜你,成功通过 Bevy ECS 运行起你的第一个 System