14 releases

0.4.2 Dec 1, 2024
0.4.1 Nov 25, 2024
0.3.11 Nov 11, 2024
0.3.10 Sep 15, 2024
0.1.0 Jul 13, 2024

#75 in Game dev

Download history 149/week @ 2024-08-19 11/week @ 2024-08-26 133/week @ 2024-09-02 194/week @ 2024-09-09 86/week @ 2024-09-16 32/week @ 2024-09-23 21/week @ 2024-09-30 14/week @ 2024-10-07 12/week @ 2024-10-14 18/week @ 2024-11-04 241/week @ 2024-11-11 50/week @ 2024-11-18 227/week @ 2024-11-25 85/week @ 2024-12-02

605 downloads per month

MIT license

155KB
3K SLoC

bevy_ecs_tiled

Crates.io docs license Crates.io Following released Bevy versions

bevy_ecs_tiled is a Bevy plugin for working with 2D tilemaps created with the Tiled map editor.

It relies upon:

Each tile or object is represented by a Bevy entity:

  • layers are children of the tilemap entity
  • tiles and objects are children of layers

Visibility and Transform are inherited: map -> layer -> tile / object

screenshot

Features

  • Orthogonal, isometric and hexagonal maps
  • Finite and infinite maps
  • Embedded and separate tileset
  • Easily spawn / despawn maps
  • Animated tiles
  • Rapier and Avian colliders added from tilesets and object layers (rapier or avian feature flag)
  • Tiled custom properties mapped to Bevy components (user_properties feature flag)

Documentation

This crate is documented in three places:

There is notably a FAQ that will hopefully answer most of your questions.

Good reading!

Getting started

Add dependencies to your Cargo.toml file:

[dependencies]
bevy = "0.14"
bevy_ecs_tiled = "0.4"
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::default())
        // 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());

    // Load the map: ensure any tile / tileset paths are relative to assets/ folder
    let map_handle: Handle<TiledMap> = asset_server.load("map.tmx");

    // Spawn the map with default options
    commands.spawn(TiledMapHandle(map_handle));
}

Please note that you should have the map.tmx file in your local assets/ folder, as well as required dependencies (for instance, associated tilesets).

You can customize various settings about how to load the map by inserting the TiledMapSettings component on the map entity.

Also, you can browse the examples for more advanced use cases.

Bevy Compatibility

bevy bevy_ecs_tilemap bevy_ecs_tiled
0.14 0.14 0.3 - 0.4
0.13 main@e4f3cc6 branch 0.2
0.12 0.12 0.1

Assets credits

Contributing

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.

LICENSE

This work is licensed under the MIT license.

SPDX-License-Identifier: MIT

Dependencies

~43–81MB
~1.5M SLoC