class Rubygame::Events::JoystickBallMoved
JoystickBallMoved is an event that occurs when a joystick's trackball has changed position.
A joystick trackball is a ball which rotates freely in a socket, controlled by the user's fingers or thumb.
A trackball reports movement on x and y axes, measured in pixels, just like a mouse does. However, a trackball does not report its current position, only its movement since the previous event.
Attributes
ball[R]
joystick_id[R]
rel[R]
Public Class Methods
new( joystick_id, ball, rel )
click to toggle source
Creates a new JoystickBallMoved instance.
- #joystick_id
-
an integer identifying which joystick changed. The first joystick is 0.
- ball
-
an integer identifying which ball changed. The first ball on each joystick is 0.
- rel
-
relative position (how much the ball moved since the previous event). [x,y], in pixels.
# File lib/rubygame/events/joystick_events.rb, line 209 def initialize( joystick_id, ball, rel ) unless joystick_id.kind_of?(Fixnum) and joystick_id >= 0 raise ArgumentError, "joystick_id must be an integer >= 0" end @joystick_id = joystick_id unless ball.kind_of?(Fixnum) and ball >= 0 raise ArgumentError, "ball must be an integer >= 0" end @ball = ball @rel = rel.to_ary.dup @rel.freeze unless @rel.length == 2 raise ArgumentError, "rel must have exactly 2 parts (got %s)"%@rel.length end end