Module bevy_tilemap::chunk[][src]

Tiles organised into chunks for efficiency and performance.

Mostly everything in this module is private API and not intended to be used outside of this crate as a lot goes on under the hood that can cause issues. With that being said, everything that can be used with helping a chunk get created does live in here.

These below examples have nothing to do with this library as all should be done through the Tilemap. These are just more specific examples which use the private API of this library.

Simple chunk creation

use bevy_asset::{prelude::*, HandleId};
use bevy_sprite::prelude::*;
use bevy_tilemap::prelude::*;

// This must be set in Asset<TextureAtlas>.
let texture_atlas_handle = Handle::weak(HandleId::random::<TextureAtlas>());

let mut tilemap = Tilemap::new(texture_atlas_handle, 32, 32);

// There are two ways to create a new chunk. Either directly...

tilemap.insert_chunk((0, 0));

// Or indirectly...

let point = (0, 0);
let sprite_index = 0;
let tile = Tile { point, sprite_index, ..Default::default() };
tilemap.insert_tile(tile);

Specifying what kind of chunk

use bevy_asset::{prelude::*, HandleId};
use bevy_sprite::prelude::*;
use bevy_tilemap::prelude::*;

// This must be set in Asset<TextureAtlas>.
let texture_atlas_handle = Handle::weak(HandleId::random::<TextureAtlas>());

let mut tilemap = Tilemap::new(texture_atlas_handle, 32, 32);

tilemap.insert_chunk((0, 0));

let sprite_order = 0;
tilemap.add_layer(TilemapLayer { kind: LayerKind::Dense, ..Default::default() }, 1);

let sprite_order = 1;
tilemap.add_layer(TilemapLayer { kind: LayerKind::Dense, ..Default::default() }, 1);

Re-exports

pub use raw_tile::RawTile;

Modules

raw_tile

Raw tile that is stored in the chunks.

Enums

LayerKind

Specifies which kind of layer to construct, either a dense or a sparse sprite layer.