pub struct ObjectLayer<'map> { /* private fields */ }Expand description
Also called an “object group”. Used for storing Objects in a map.
Implementations§
Source§impl<'map> ObjectLayer<'map>
impl<'map> ObjectLayer<'map>
Source§impl<'map> ObjectLayer<'map>
impl<'map> ObjectLayer<'map>
Sourcepub fn get_object(&self, idx: usize) -> Option<Object<'map>>
pub fn get_object(&self, idx: usize) -> Option<Object<'map>>
Obtains the object corresponding to the index given.
Sourcepub fn objects(&self) -> impl ExactSizeIterator<Item = Object<'map>> + 'map
pub fn objects(&self) -> impl ExactSizeIterator<Item = Object<'map>> + 'map
Returns an iterator over the objects present in this layer, in the order they were declared in in the TMX file.
§Example
use tiled::Object;
let spawnpoints: Vec<Object> = map
.layers()
.filter_map(|layer| match layer.layer_type() {
tiled::LayerType::Objects(layer) => Some(layer),
_ => None,
})
.flat_map(|layer| layer.objects())
.filter(|object| object.user_type == "spawn")
.collect();
dbg!(spawnpoints);Methods from Deref<Target = ObjectLayerData>§
Sourcepub fn object_data(&self) -> &[ObjectData]
pub fn object_data(&self) -> &[ObjectData]
Returns the data belonging to the objects contained within the layer, in the order they were declared in the TMX file.
Trait Implementations§
Source§impl<'map> Clone for ObjectLayer<'map>
impl<'map> Clone for ObjectLayer<'map>
Source§fn clone(&self) -> ObjectLayer<'map>
fn clone(&self) -> ObjectLayer<'map>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'map> Debug for ObjectLayer<'map>
impl<'map> Debug for ObjectLayer<'map>
Source§impl<'map> Deref for ObjectLayer<'map>
impl<'map> Deref for ObjectLayer<'map>
Source§impl<'map> PartialEq for ObjectLayer<'map>
impl<'map> PartialEq for ObjectLayer<'map>
impl<'map> Copy for ObjectLayer<'map>
impl<'map> StructuralPartialEq for ObjectLayer<'map>
Auto Trait Implementations§
impl<'map> Freeze for ObjectLayer<'map>
impl<'map> RefUnwindSafe for ObjectLayer<'map>
impl<'map> Send for ObjectLayer<'map>
impl<'map> Sync for ObjectLayer<'map>
impl<'map> Unpin for ObjectLayer<'map>
impl<'map> UnwindSafe for ObjectLayer<'map>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more