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

Instance Method Summary collapse

Instance Attribute Details

#buttonObject (readonly)

Returns the value of attribute button.



33
34
35
# File 'lib/rubygame/events/mouse_events.rb', line 33

def button
  @button
end

#posObject (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, button )

  unless button.kind_of? Symbol
    raise ArgumentError, "button must be a :symbol"
  end

  @button = button

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

end