Crate bevy_tileset

source ·
Expand description

bevy_tileset

Simple, configurable tilesets in Bevy using RON.

This crate provides a way for tilesets to be constructed at runtime either manually in the code or automatically with configuration files.

Usaage

Simply define your tiles and tilesets in config files:

// assets/tiles/my_tile.ron
(
  name: "My Tile",
  tile: Standard("textures/my_tile.png")
)
// assets/my_tileset.ron
(
  name: Some("My Awesome Tileset"),
  id: 0,
  tiles: {
    0: "../tiles/my_tile.ron",
    // ...
  }
)

And load it in via a system:

use bevy::prelude::*;
use bevy_tileset::prelude::*;

fn load_tiles(asset_server: Res<AssetServer>) {
  let handle: Handle<Tileset> = asset_server.load("my_tileset.ron");
  // Store handle...
}

Then access the generated tileset from anywhere:

use bevy_tileset::prelude::*;
fn my_system(tilesets: Tilesets, /* other system params */) {

  let tileset = tilesets.get_by_name("My Awesome Tileset").unwrap();
  let tile_index = tileset.get_tile_index("My Tile").unwrap();

  match tile_index {
    TileIndex::Standard(texture_index) => { /* Do something */ },
    TileIndex::Animated(start, end, speed) => { /* Do something */ },
  }
}

Crate Features

  • default - No features automatically enabled
  • variants - Enables usage of Variant tiles
  • auto-tile - Enables usage of Auto tiles

Re-exports

Modules

  • Module containing items for debugging
  • The main module to import when using this crate