To draw 2-dimensional objects including images and any kind of shapes, we need to spawn a Camera2dBundle.
use bevy::{
app::{App, Startup},
core_pipeline::core_2d::Camera2dBundle,
ecs::system::Commands,
DefaultPlugins,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
}
The Camera2dBundle contains a Camera component. The component decides where to draw 2-dimensional objects, such as on which window and on which rectangular area of the window. The default is to draw on the whole primary window.
➡️ Next: The Background Color
📘 Back: Table of contents