Class: Rubygame::Events::MouseMoved

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygame/events/mouse_events.rb

Overview

MouseMoved is an event class which occurs when the mouse cursor moves. It has attribute readers for #pos (new position), #rel (change since the last MouseMoved event), and #buttons (an Array of the mouse buttons that were held down while moving).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pos, rel, buttons = []) ⇒ MouseMoved

Create a new MouseReleased instance.

pos

an Array for the new position of the mouse cursor. The point [0,0] is the top-left corner of the window (or the screen if running full-screen). (Array, required)

rel

an Array for the position change since the last MouseMoved event, in pixels. (Array, required)

buttons

an Array of symbols for the mouse buttons that were being held down while the mouse was moving. [] if no buttons were being held. (Array, optional)



140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/rubygame/events/mouse_events.rb', line 140

def initialize( pos, rel, buttons=[] )

  @pos = pos.to_ary.dup
  @pos.freeze

  @rel = rel.to_ary.dup
  @rel.freeze

  @buttons = buttons.to_ary.dup
  @buttons.freeze

end

Instance Attribute Details

#buttonsObject (readonly)

Returns the value of attribute buttons.



123
124
125
# File 'lib/rubygame/events/mouse_events.rb', line 123

def buttons
  @buttons
end

#posObject (readonly)

Returns the value of attribute pos.



123
124
125
# File 'lib/rubygame/events/mouse_events.rb', line 123

def pos
  @pos
end

#relObject (readonly)

Returns the value of attribute rel.



123
124
125
# File 'lib/rubygame/events/mouse_events.rb', line 123

def rel
  @rel
end