Enum macroquad_virtual_joystick::JoystickDirection[][src]

pub enum JoystickDirection {
    Up,
    UpLeft,
    Left,
    DownLeft,
    Down,
    DownRight,
    Right,
    UpRight,
    Idle,
}

different directions of the Joystick

Variants

Up
UpLeft
Left
DownLeft
Down
DownRight
Right
UpRight
Idle

Implementations

impl JoystickDirection[src]

pub fn from_degrees(degrees: f64) -> Self[src]

calculate a JoystickDirection from degrees

0 degrees are on the positive X-Axis and then it rotates clockwise

Examples

use macroquad_virtual_joystick::JoystickDirection;

let degrees = 153.5;
let direction = JoystickDirection::from_degrees(degrees);

assert_eq!(direction, JoystickDirection::DownLeft);

pub fn to_local(&self) -> Vec2[src]

convert the direction to a Vec2 with x and y

x and y are both one of these: [-1.0, 0.0, 1.0]

Examples

use macroquad::prelude::Vec2;
use macroquad_virtual_joystick::JoystickDirection;

let direction = JoystickDirection::Up;
assert_eq!(direction.to_local(), Vec2::new(0.0, -1.0))

Trait Implementations

impl Clone for JoystickDirection[src]

impl Copy for JoystickDirection[src]

impl Debug for JoystickDirection[src]

impl Eq for JoystickDirection[src]

impl PartialEq<JoystickDirection> for JoystickDirection[src]

impl StructuralEq for JoystickDirection[src]

impl StructuralPartialEq for JoystickDirection[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.