[−][src]Struct bevy_tilemap::tilemap::Builder
Tilemap factory, which can be used to construct and configure new tilemaps.
Methods can be chained in order to configure it. The texture_atlas
method is required in order to have a successful factory creation.
The configuration options available are:
dimensions
: specifies the dimensions of the tilemap. If this is not set, then the tilemap will have no dimensions.chunk_dimensions
: specifies the chunk's dimensions in tiles. Default is 32x, 32y.tile_dimensions
: specifies the tile's dimensions in pixels. Default is 32px, 32px.z_layers
: specifies the maximum number of layers that sprites can exist on. Default is 20.texture_atlas
: specifies the texture atlas handle to use for the tilemap.
The build
method will take ownership and consume the builder returning
a TilemapResult
with either an TilemapError
or the tilemap.
Examples
use bevy_tilemap::tilemap; use bevy::asset::HandleId; use bevy::prelude::*; let texture_atlas_handle = Handle::weak(HandleId::random::<TextureAtlas>()); let builder = tilemap::Builder::new().texture_atlas(texture_atlas_handle); let tilemap = builder.build().unwrap();
Can also get a builder like this:
use bevy_tilemap::tilemap::Tilemap; use bevy::asset::HandleId; use bevy::prelude::*; let texture_atlas_handle = Handle::weak(HandleId::random::<TextureAtlas>()); let builder = Tilemap::builder().texture_atlas(texture_atlas_handle); let tilemap = builder.build().unwrap();
Implementations
impl Builder
[src]
pub fn new() -> Builder
[src]
Configures the builder with the default settings.
Is equivalent to default
and builder
method in the
tilemap. Start with this then you are able to method chain.
Examples
use bevy_tilemap::tilemap::{self, Tilemap}; let builder = tilemap::Builder::new(); // Equivalent to... let builder = tilemap::Builder::default(); // Or... let builder = Tilemap::builder();
pub fn dimensions(self, width: u32, height: u32) -> Builder
[src]
Sets the dimensions of the tilemap.
If this is not set then the tilemap will be boundless entirely.
Examples
use bevy_tilemap::tilemap; let builder = tilemap::Builder::new().dimensions(5, 5);
pub fn chunk_dimensions(self, width: u32, height: u32) -> Builder
[src]
Sets the chunk dimensions.
Chunk dimensions are in tiles. If this is not set then the default of 32x, 32y is used.
Examples
use bevy_tilemap::tilemap; let builder = tilemap::Builder::new().chunk_dimensions(32, 32);
pub fn tile_dimensions(self, width: u32, height: u32) -> Builder
[src]
Sets the tile dimensions.
Tile dimensions are in pixels. If this is not set then the default of 32px, 32px is used.
Examples
use bevy_tilemap::tilemap; let builder = tilemap::Builder::new().tile_dimensions(32, 32);
pub fn z_layers(self, layers: usize) -> Builder
[src]
Sets the amount of render layers that sprites can exist on.
By default there are 20 if this is not set.
Examples
use bevy_tilemap::tilemap; let builder = tilemap::Builder::new().z_layers(5);
pub fn add_layer(self, kind: LayerKind, z_layer: usize) -> Builder
[src]
Adds a sprite layer that sprites can exist on.
Takes in a LayerKind
and a Z layer and adds it to the builder.
If there are more layers than Z layers is set, builder will construct a tilemap with that many layers instead. In the case that a layer is added twice to the same Z layer, the first layer will be overwritten by the later.
Examples
use bevy_tilemap::tilemap; use bevy_tilemap::chunk::LayerKind; let builder = tilemap::Builder::new() .add_layer(LayerKind::Dense, 0) .add_layer(LayerKind::Sparse, 1) .add_layer(LayerKind::Sparse, 2);
pub fn texture_atlas(self, handle: Handle<TextureAtlas>) -> Builder
[src]
Sets the texture atlas, this is required to be set.
Examples
use bevy_tilemap::tilemap; use bevy::asset::HandleId; use bevy::prelude::*; let texture_atlas_handle = Handle::weak(HandleId::random::<TextureAtlas>()); let builder = tilemap::Builder::new().texture_atlas(texture_atlas_handle);
pub fn build(self) -> TilemapResult<Tilemap>
[src]
Consumes the builder and returns a result.
If successful a TilemapResult
is return with tilemap on
succes or a TilemapError
if there is an issue.
Errors
If a texture atlas is not set this is the only way that an error can
occur. If this happens, be sure to use texture_atlas
.
Examples
use bevy_tilemap::tilemap; use bevy::asset::HandleId; use bevy::prelude::*; let texture_atlas_handle = Handle::weak(HandleId::random::<TextureAtlas>()); let builder = tilemap::Builder::new().texture_atlas(texture_atlas_handle); let tilemap = builder.build();
Trait Implementations
impl Clone for Builder
[src]
impl Debug for Builder
[src]
impl Default for Builder
[src]
impl Eq for Builder
[src]
impl PartialEq<Builder> for Builder
[src]
impl StructuralEq for Builder
[src]
impl StructuralPartialEq for Builder
[src]
Auto Trait Implementations
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
T: Clone + Any,
impl<T> Component for T where
T: 'static + Send + Sync,
T: 'static + Send + Sync,
impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> DowncastSync for T where
T: Send + Sync + Any,
T: Send + Sync + Any,
impl<T> From<T> for T
[src]
impl<T> FromResources for T where
T: Default,
T: Default,
pub fn from_resources(_resources: &Resources) -> T
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Resource for T where
T: 'static + Send + Sync,
T: 'static + Send + Sync,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,