结束应用
为了干净利落地关闭 bevy,可以从任何系统中发送一个 AppExit
事件。
use bevy::app::AppExit;
fn exit_system(mut exit: EventWriter<AppExit>) {
exit.send(AppExit);
}
为原型设计开发过程方便退出应用,bevy 提供了一个系统,你可以添加到你的应用程序中,当你按下 Esc 键时应用直接关闭退出。
For prototyping, bevy provides a system you can add to your
App
, to exit on pressing the Esc
key:
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_system(bevy::input::system::exit_on_esc_system)
.run();
}