Module: Rubygame::Events::MouseButtonEvent
- Included in:
- MousePressed, MouseReleased
- Defined in:
- lib/rubygame/events/mouse_events.rb
Overview
MouseButtonEvent is a mixin module included in the MousePressed and MouseReleased classes. It defines the #button and #pos attribute readers.
Instance Attribute Summary collapse
-
#button ⇒ Object
readonly
Returns the value of attribute button.
-
#pos ⇒ Object
readonly
Returns the value of attribute pos.
Instance Method Summary collapse
-
#initialize(pos, button) ⇒ Object
Initialize the MouseButtonEvent.
Instance Attribute Details
#button ⇒ Object (readonly)
Returns the value of attribute button.
33 34 35 |
# File 'lib/rubygame/events/mouse_events.rb', line 33 def end |
#pos ⇒ Object (readonly)
Returns the value of attribute pos.
33 34 35 |
# File 'lib/rubygame/events/mouse_events.rb', line 33 def pos @pos end |
Instance Method Details
#initialize(pos, button) ⇒ Object
Initialize the MouseButtonEvent.
- button
-
a symbol for the button that was pressed or released. (Symbol, required)
- pos
-
an Array for the position of the mouse cursor when the event occured. [0,0] is the top-left corner of the window (or the screen if running full-screen). (Array, required)
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rubygame/events/mouse_events.rb', line 46 def initialize( pos, ) unless .kind_of? Symbol raise ArgumentError, "button must be a :symbol" end = @pos = pos.to_ary.dup @pos.freeze end |