mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
81b53d15d4
Resolves #1253 #1562 This makes the Commands apis consistent with World apis. This moves to a "type state" pattern (like World) where the "current entity" is stored in an `EntityCommands` builder. In general this tends to cuts down on indentation and line count. It comes at the cost of needing to type `commands` more and adding more semicolons to terminate expressions. I also added `spawn_bundle` to Commands because this is a common enough operation that I think its worth providing a shorthand.
21 lines
544 B
Rust
21 lines
544 B
Rust
use bevy::prelude::*;
|
|
|
|
fn main() {
|
|
App::build()
|
|
.add_plugins(DefaultPlugins)
|
|
.add_startup_system(setup.system())
|
|
.run();
|
|
}
|
|
|
|
fn setup(
|
|
mut commands: Commands,
|
|
asset_server: Res<AssetServer>,
|
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
|
) {
|
|
let texture_handle = asset_server.load("branding/icon.png");
|
|
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
|
|
commands.spawn_bundle(SpriteBundle {
|
|
material: materials.add(texture_handle.into()),
|
|
..Default::default()
|
|
});
|
|
}
|