generated from loopystudios/bevy-shell-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.rs
27 lines (24 loc) · 742 Bytes
/
map.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use bevy::prelude::*;
use bevy_ecs_ldtk::prelude::*;
pub struct MapPlugin;
impl Plugin for MapPlugin {
fn build(&self, app: &mut App) {
app.add_plugin(LdtkPlugin)
.insert_resource(LevelSelection::Index(0))
.add_startup_system(setup)
.register_ldtk_entity::<MyBundle>("MyEntityIdentifier");
}
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn_bundle(Camera2dBundle::default());
commands.spawn_bundle(LdtkWorldBundle {
ldtk_handle: asset_server.load("map/map.ldtk"),
..Default::default()
});
}
#[derive(Bundle, LdtkEntity)]
pub struct MyBundle {
#[sprite_sheet_bundle]
#[bundle]
sprite_bundle: SpriteSheetBundle,
}