pub struct TouchPad<A: UiAction> { /* private fields */ }Expand description
The virtual stick and its tap buttons, pushing into the kit’s action sink.
Owned by the app for the life of the game, like the games’ own touch state: the pad holds the finger that is down, its origin and the gate.
Implementations§
Source§impl<A: UiAction> TouchPad<A>
impl<A: UiAction> TouchPad<A>
Sourcepub fn with_zone(self, fraction: f32) -> Result<Self, TouchError>
pub fn with_zone(self, fraction: f32) -> Result<Self, TouchError>
Cover a different fraction of the viewport width with the stick’s zone.
pub fn kit(&self) -> &Kit<A>
Sourcepub fn stick(&self) -> Vec2
pub fn stick(&self) -> Vec2
The stick’s value: dead-zoned, clamped to the unit disc, y down.
Poll it where the game already combines its move axes; it is not an action because movement is a level, not an edge.
Sourcepub fn begin_frame(&self, flow: FlowState)
pub fn begin_frame(&self, flow: FlowState)
Per-frame gate: the pad takes pointers only while the game owns input.
Call before composing (or before the sim step) with the same
FlowState the gameplay systems read. Closing the gate releases a
finger that is still down, so the game cannot keep moving under a modal.
Sourcepub fn begin_frame_in(&self, world: &World)
pub fn begin_frame_in(&self, world: &World)
Per-frame gate read straight from the sim world.
A world where the flow was never installed reads as
FlowState::CLOSED, so the overlay is closed rather than live.
Sourcepub fn view(&self, viewport: [f32; 2]) -> View
pub fn view(&self, viewport: [f32; 2]) -> View
The stick’s touch zone and ring, to be composed over the game.
Nothing is composed while the gate is closed.
Sourcepub fn tap(
&self,
viewport: [f32; 2],
glyph: &str,
at: [f32; 2],
radius: f32,
action: A,
) -> View
pub fn tap( &self, viewport: [f32; 2], glyph: &str, at: [f32; 2], radius: f32, action: A, ) -> View
A round tap button at a design-space point, pushing action on release.
Sized like the glyph buttons and placed absolutely, so it can sit under the thumb. Touch buttons stay out of keyboard traversal: a finger is not a focus.
Trait Implementations§
Auto Trait Implementations§
impl<A> !RefUnwindSafe for TouchPad<A>
impl<A> !Send for TouchPad<A>
impl<A> !Sync for TouchPad<A>
impl<A> !UnwindSafe for TouchPad<A>
impl<A> Freeze for TouchPad<A>
impl<A> Unpin for TouchPad<A>
impl<A> UnsafeUnpin for TouchPad<A>where
Kit<A>: UnsafeUnpin,
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>, which can then be
downcast into Box<dyn 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>, which 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.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.