Struct macroquad_virtual_joystick::Joystick [−][src]
pub struct Joystick { /* fields omitted */ }The joystick component
Examples
use macroquad_virtual_joystick::Joystick; let center_x = 100.0; let center_y = 50.0; let size = 50.0; // create a new joystick let mut joystick = Joystick::new(center_x, center_y, size); // render the joystick and determine the action let joystick_action = joystick.update();
Implementations
impl Joystick[src]
impl Joystick[src]pub fn new(x: f32, y: f32, size: f32) -> Self[src]
create a new joystick
Arguments
x,y: center of the joysticksize: diameter of the joystick
Examples
use macroquad_virtual_joystick::Joystick; let center_x = 100.0; let center_y = 50.0; let size = 50.0; let joystick = Joystick::new(center_x, center_y, size);
pub fn from_custom_elements(
x: f32,
y: f32,
size: f32,
background: Option<JoystickElement>,
knob: Option<JoystickElement>
) -> Self[src]
x: f32,
y: f32,
size: f32,
background: Option<JoystickElement>,
knob: Option<JoystickElement>
) -> Self
create a new Joystick with custom elements for background and knob
Arguments
x,y: center of the joysticksize: diameter of the joystick, should have the same size as the background elementbackground,knob: custom elements
Examples
use macroquad::prelude::Color; use macroquad_virtual_joystick::{Joystick, JoystickElement}; let center_x = 100.0; let center_y = 50.0; let radius = 50.0; let background_color = Color::from_rgba(255, 0, 0, 255); let knob_color = Color::from_rgba(0, 255, 0, 255); // create the background element let background = JoystickElement::new( center_x, center_y, radius, background_color, ); // create the knob element let knob = JoystickElement::new( center_x, center_y, radius * 0.75, knob_color, ); let joystick = Joystick::from_custom_elements( center_x, center_y, radius * 2.0, Some(background), Some(knob), );
pub fn update(&mut self) -> JoystickDirectionalEvent[src]
update the joystick
this updates the joystick and renders it
returns the current JoystickDirectionalEvent
Examples
see Joystick
Auto Trait Implementations
impl RefUnwindSafe for Joystick
impl RefUnwindSafe for Joystickimpl UnwindSafe for Joystick
impl UnwindSafe for Joystick