Class | Rubygame::Events::JoystickHatMoved
In: | lib/rubygame/events/joystick_events.rb
Parent: | Object

JoystickHatMoved is an event that occurs when a joystick‘s hat switch has changed direction.

A joystick hat switch is a round switch that can be pressed in 8 possible directions: up, down, left, right, or the four diagonal directions. (Some hat switches support extra diagonal directions, but only those 8 directions are supported by Rubygame.)

### Methods

center? down? left? new right? up?

### Attributes

direction | [R] |
hat | [R] |
horizontal | [R] |
joystick_id | [R] |
vertical | [R] |

### Public Class methods

new( joystick_id, hat, direction )

Creates a new JoystickHatMoved instance.

joystick_id: | an integer identifying which joystick changed. The first joystick is 0.
hat: | an integer identifying which hat switch changed. The first hat switch on each joystick is 0.
direction: | a symbol telling the direction the hat switch is being pressed. The direction is either nil or one of these 8 symbols: :up :up_right :right :down_right :down :down_left :left :up_left

### Public Instance methods

center?()

True if the hat is in the center (not pressed in any direction).

down?()

True if the hat is pressed down, down-right, or down-left.

left?()

True if the hat is pressed left, up-left, or down-left.

right?()

True if the hat is pressed right, up-right, or down-right.

up?()

True if the hat is pressed up, up-right, or up-left.

[Validate]