pub struct DigitalMovement2d<A: Action> { /* private fields */ }Expand description
Constant-speed movement driven by a typed digital input axis.
Spawning this component without a Transform2d automatically inserts a
default transform at the world origin. The component stores movement
configuration but does not read input or move by itself. Explicitly
register the standard adapter with
crate::app::Application::add_digital_movement2d_system. Physical key
bindings remain separate application configuration. Application<A>::new
approves DigitalMovement2d<A> for that exact action type; movement
components instantiated with another action type are not implicitly
approved in the same application.
Digital input is normalized before applying speed, so cardinal and
diagonal movement have the same magnitude. An idle or exactly opposed
direction is a no-op before speed/time multiplication. This adapter does
not perform collision detection or response, acceleration, facing, or
analog input.
Implementations§
Source§impl<A: Action> DigitalMovement2d<A>
impl<A: Action> DigitalMovement2d<A>
Sourcepub fn new(
axis: DigitalAxis2d<A>,
speed: f32,
) -> Result<Self, DigitalMovement2dError>
pub fn new( axis: DigitalAxis2d<A>, speed: f32, ) -> Result<Self, DigitalMovement2dError>
Creates movement for one typed digital axis at a finite nonnegative speed.
Sourcepub const fn axis(&self) -> DigitalAxis2d<A>
pub const fn axis(&self) -> DigitalAxis2d<A>
Returns the four-action axis sampled by the standard adapter.
Sourcepub const fn speed(&self) -> f32
pub const fn speed(&self) -> f32
Returns the constant movement speed in world units per second.
Sourcepub fn set_axis(&mut self, axis: DigitalAxis2d<A>)
pub fn set_axis(&mut self, axis: DigitalAxis2d<A>)
Replaces the infallible typed axis descriptor.
Trait Implementations§
Source§impl<A: Action> Component for DigitalMovement2d<A>
Required Components: Transform2d.
impl<A: Action> Component for DigitalMovement2d<A>
Required Components: Transform2d.
A component’s Required Components are inserted whenever it is inserted. Note that this will also insert the required components of the required components, recursively, in depth-first order.
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreimpl<A: Copy + Action> Copy for DigitalMovement2d<A>
impl<A: PartialEq + Action> StructuralPartialEq for DigitalMovement2d<A>
Auto Trait Implementations§
impl<A> Freeze for DigitalMovement2d<A>where
DigitalAxis2d<A>: Freeze,
impl<A> RefUnwindSafe for DigitalMovement2d<A>where
DigitalAxis2d<A>: RefUnwindSafe,
impl<A> Send for DigitalMovement2d<A>where
DigitalAxis2d<A>: Send,
impl<A> Sync for DigitalMovement2d<A>where
DigitalAxis2d<A>: Sync,
impl<A> Unpin for DigitalMovement2d<A>where
DigitalAxis2d<A>: Unpin,
impl<A> UnsafeUnpin for DigitalMovement2d<A>where
DigitalAxis2d<A>: UnsafeUnpin,
impl<A> UnwindSafe for DigitalMovement2d<A>where
DigitalAxis2d<A>: UnwindSafe,
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
Source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.