Class: Rubygame::Events::JoystickBallMoved
- Inherits:
-
Object
- Object
- Rubygame::Events::JoystickBallMoved
- Defined in:
- lib/rubygame/events/joystick_events.rb
Overview
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.
Instance Attribute Summary collapse
-
#ball ⇒ Object
readonly
Returns the value of attribute ball.
-
#joystick_id ⇒ Object
readonly
Returns the value of attribute joystick_id.
-
#rel ⇒ Object
readonly
Returns the value of attribute rel.
Instance Method Summary collapse
-
#initialize(joystick_id, ball, rel) ⇒ JoystickBallMoved
constructor
Creates a new JoystickBallMoved instance.
Constructor Details
#initialize(joystick_id, ball, rel) ⇒ JoystickBallMoved
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.
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# 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 |
Instance Attribute Details
#ball ⇒ Object (readonly)
Returns the value of attribute ball.
196 197 198 |
# File 'lib/rubygame/events/joystick_events.rb', line 196 def ball @ball end |
#joystick_id ⇒ Object (readonly)
Returns the value of attribute joystick_id.
195 196 197 |
# File 'lib/rubygame/events/joystick_events.rb', line 195 def joystick_id @joystick_id end |
#rel ⇒ Object (readonly)
Returns the value of attribute rel.
197 198 199 |
# File 'lib/rubygame/events/joystick_events.rb', line 197 def rel @rel end |