pub struct DPad {
pub left: bool,
pub right: bool,
pub up: bool,
pub down: bool,
}
Expand description
DPad-like representation of the Pad
.
Constructed with Pad::as_dpad
. Useful for simple games and ports.
The middle of the pad is a “dead zone” pressing which will not activate any direction.
Invariant: it’s not possible for opposite directions (left and right, or down and up) to be active at the same time. However, it’s possible for heighboring directions (like up and right) to be active at the same time if the player presses a diagonal.
Fields§
§left: bool
§right: bool
§up: bool
§down: bool
Implementations§
Source§impl DPad
impl DPad
Sourcepub fn just_pressed(&self, old: &Self) -> Self
pub fn just_pressed(&self, old: &Self) -> Self
Given the old state, get directions that were not pressed but are pressed now.
Sourcepub fn just_released(&self, old: &Self) -> Self
pub fn just_released(&self, old: &Self) -> Self
Given the old state, get directions that were pressed but aren’t pressed now.
Trait Implementations§
Source§impl Ord for DPad
impl Ord for DPad
Source§impl PartialOrd for DPad
impl PartialOrd for DPad
impl Copy for DPad
impl Eq for DPad
impl StructuralPartialEq for DPad
Auto Trait Implementations§
impl Freeze for DPad
impl RefUnwindSafe for DPad
impl Send for DPad
impl Sync for DPad
impl Unpin for DPad
impl UnwindSafe for DPad
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