pub struct DPad8 {
pub left: bool,
pub right: bool,
pub up: bool,
pub down: bool,
}Expand description
8-directional DPad-like representation of the Pad.
Constructed with Pad::as_dpad8. Useful for simple games and ports.
The middle of the pad is a “dead zone” pressing which will not activate any direction.
Implements all the same methods as DPad4.
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.
For completeness, here is the full list of possible states:
- right
- right and up
- up
- left and up
- left
- left and down
- down
- right and down
- none
Fields§
§left: bool§right: bool§up: bool§down: boolImplementations§
Source§impl DPad8
impl DPad8
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 DPad8
impl Ord for DPad8
Source§impl PartialOrd for DPad8
impl PartialOrd for DPad8
impl Copy for DPad8
impl Eq for DPad8
impl StructuralPartialEq for DPad8
Auto Trait Implementations§
impl Freeze for DPad8
impl RefUnwindSafe for DPad8
impl Send for DPad8
impl Sync for DPad8
impl Unpin for DPad8
impl UnwindSafe for DPad8
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