bevy_ecs_tiled
is a Bevy plugin for working with 2D tilemaps created with the Tiled map editor.
It relies upon:
bevy_ecs_tilemap
crate to perform renderingEach tile or object is represented by a Bevy entity:
Visibility
and Transform
are inherited: map -> layer -> tile / object
rapier
or avian
feature flag)user_properties
feature flag)This crate is documented in three places:
bevy_ecs_tiled
book with design explanation and how-to guides.Good reading!
Add dependencies to your Cargo.toml
file:
[dependencies]
bevy = "0.14"
bevy_ecs_tiled = "0.3"
bevy_ecs_tilemap = "0.14"
Then add the plugin to your app and spawn a map:
use bevy::prelude::*;
use bevy_ecs_tiled::prelude::*;
use bevy_ecs_tilemap::prelude::*;
fn main() {
App::new()
// Add Bevy default plugins
.add_plugins(DefaultPlugins)
// Add bevy_ecs_tilemap plugin
.add_plugins(TilemapPlugin)
// Add bevy_ecs_tiled plugin
.add_plugins(TiledMapPlugin)
// Add our startup function to the schedule and run the app
.add_systems(Startup, startup)
.run();
}
fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
// Spawn a 2D camera
commands.spawn(Camera2dBundle::default());
// Ensure any tile / tileset paths are relative to assets/
let map_handle: Handle<TiledMap> = asset_server.load("map.tmx");
commands.spawn(TiledMapBundle {
tiled_map: map_handle,
..Default::default()
});
}
Please note that you should have the map.tmx
file in your local assets/
folder (as well as required dependencies, for instance associated tilesets).
bevy | bevy_ecs_tilemap | bevy_ecs_tiled |
---|---|---|
0.14 | 0.14 | 0.3 |
0.13 | main@e4f3cc6 | branch 0.2 |
0.12 | 0.12 | 0.1 |
If you can contribute, please do!
If you would like to contribute but don't know where to start, read this section in the book.
This work is licensed under the MIT license.
SPDX-License-Identifier: MIT