Struct let_engine::Layer
source · pub struct Layer {
pub root: NObject,
pub camera: Arc<Mutex<Option<Box<dyn Camera>>>>,
/* private fields */
}
Fields§
§root: NObject
§camera: Arc<Mutex<Option<Box<dyn Camera>>>>
Implementations§
source§impl Layer
impl Layer
pub fn new(root: NObject) -> Self
pub fn set_camera<T: Camera + 'static>(&self, camera: T)
sourcepub fn side_to_world(&self, direction: [f32; 2], dimensions: (f32, f32)) -> Vec2
pub fn side_to_world(&self, direction: [f32; 2], dimensions: (f32, f32)) -> Vec2
Be careful! Don’t use this when the camera is locked.
pub fn contains_object(&self, object_id: &usize) -> bool
pub fn gravity(&self) -> Vec2
pub fn set_gravity(&self, gravity: Vec2)
pub fn physics_enabled(&self) -> bool
pub fn set_physics_enabled(&self, enabled: bool)
pub fn physics_parameters(&self) -> IntegrationParameters
pub fn set_physics_parameters(&self, parameters: IntegrationParameters)
pub fn add_joint( &self, object1: &impl GameObject, object2: &impl GameObject, data: impl Into<GenericJoint>, wake_up: bool ) -> Result<ImpulseJointHandle, NoRigidBodyError>
pub fn get_joint(&self, handle: ImpulseJointHandle) -> Option<GenericJoint>
pub fn set_joint( &self, data: impl Into<GenericJoint>, handle: ImpulseJointHandle ) -> Result<(), NoJointError>
pub fn remove_joint(&self, handle: ImpulseJointHandle, wake_up: bool)
pub fn add_object_with_optional_parent<T: GameObject + Clone + 'static>( &self, parent: Option<&T>, object: &mut T ) -> Result<(), NoParentError>
pub fn add_object<T: GameObject + Clone + 'static>(&self, object: &mut T)
pub fn add_object_with_parent<T: GameObject + Clone + 'static>( &self, parent: &T, object: &mut T ) -> Result<(), NoParentError>
sourcepub fn remove_object(
&self,
object: &mut impl GameObject
) -> Result<(), NoObjectError>
pub fn remove_object( &self, object: &mut impl GameObject ) -> Result<(), NoObjectError>
Removes an object using it’s ID.
sourcepub fn query_nearest_collider_at(&self, position: Vec2) -> Option<usize>
pub fn query_nearest_collider_at(&self, position: Vec2) -> Option<usize>
Returns the nearest collider id from a specific location.
sourcepub fn cast_ray(
&self,
position: Vec2,
direction: Vec2,
time_of_impact: Real,
solid: bool
) -> Option<usize>
pub fn cast_ray( &self, position: Vec2, direction: Vec2, time_of_impact: Real, solid: bool ) -> Option<usize>
Returns id of the first collider intersecting with given ray.
sourcepub fn intersection_with_shape(
&self,
shape: Shape,
position: (Vec2, f32)
) -> Option<usize>
pub fn intersection_with_shape( &self, shape: Shape, position: (Vec2, f32) ) -> Option<usize>
Cast a shape and return the first collider intersecting with it.
pub fn move_to( &self, object: &impl GameObject, index: usize ) -> Result<(), Box<dyn Error>>
pub fn move_down(&self, object: &impl GameObject) -> Result<(), Box<dyn Error>>
pub fn move_up(&self, object: &impl GameObject) -> Result<(), Box<dyn Error>>
pub fn move_to_bottom( &self, object: &impl GameObject ) -> Result<(), NoObjectError>
pub fn move_to_top(&self, object: &impl GameObject) -> Result<(), NoObjectError>
pub fn children_count( &self, parent: &impl GameObject ) -> Result<usize, NoObjectError>
Trait Implementations§
source§impl PartialEq for Layer
impl PartialEq for Layer
impl Eq for Layer
Auto Trait Implementations§
impl !RefUnwindSafe for Layer
impl Send for Layer
impl Sync for Layer
impl Unpin for Layer
impl !UnwindSafe for Layer
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.