Class: Lotu::Cursor
Instance Attribute Summary collapse
-
#arrow_speed ⇒ Object
Returns the value of attribute arrow_speed.
-
#click_x ⇒ Object
readonly
Returns the value of attribute click_x.
-
#click_y ⇒ Object
readonly
Returns the value of attribute click_y.
Attributes inherited from Actor
Instance Method Summary collapse
-
#click ⇒ Object
This is the method you want to call when a user press the “click” key of your preference with something like: set_keys Gosu::Button::MsLeft => :click It’ll yield the x, y coordinates of the click.
- #down ⇒ Object
-
#initialize ⇒ Cursor
constructor
A new instance of Cursor.
- #last_click ⇒ Object
- #left ⇒ Object
- #right ⇒ Object
- #up ⇒ Object
- #update ⇒ Object
Methods inherited from Actor
Methods included from Resourceful
Methods included from Drawable
Methods included from Controllable
Methods included from Eventful
Constructor Details
#initialize ⇒ Cursor
Returns a new instance of Cursor.
7 8 9 10 11 |
# File 'lib/lotu/cursor.rb', line 7 def initialize super @click_x = @click_y = 0 @arrow_speed = 1 end |
Instance Attribute Details
#arrow_speed ⇒ Object
Returns the value of attribute arrow_speed.
5 6 7 |
# File 'lib/lotu/cursor.rb', line 5 def arrow_speed @arrow_speed end |
#click_x ⇒ Object (readonly)
Returns the value of attribute click_x.
4 5 6 |
# File 'lib/lotu/cursor.rb', line 4 def click_x @click_x end |
#click_y ⇒ Object (readonly)
Returns the value of attribute click_y.
4 5 6 |
# File 'lib/lotu/cursor.rb', line 4 def click_y @click_y end |
Instance Method Details
#click ⇒ Object
This is the method you want to call when a user press the “click” key of your preference with something like: set_keys Gosu::Button::MsLeft => :click It’ll yield the x, y coordinates of the click
22 23 24 25 26 |
# File 'lib/lotu/cursor.rb', line 22 def click @click_x = $window.mouse_x @click_y = $window.mouse_y fire(:click, @click_x, @click_y) end |
#down ⇒ Object
32 33 34 |
# File 'lib/lotu/cursor.rb', line 32 def down $window.mouse_y += @arrow_speed end |
#last_click ⇒ Object
44 45 46 |
# File 'lib/lotu/cursor.rb', line 44 def last_click "#{@click_x}, #{@click_y}" end |
#left ⇒ Object
36 37 38 |
# File 'lib/lotu/cursor.rb', line 36 def left $window.mouse_x -= @arrow_speed end |
#right ⇒ Object
40 41 42 |
# File 'lib/lotu/cursor.rb', line 40 def right $window.mouse_x += @arrow_speed end |
#up ⇒ Object
28 29 30 |
# File 'lib/lotu/cursor.rb', line 28 def up $window.mouse_y -= @arrow_speed end |
#update ⇒ Object
13 14 15 16 |
# File 'lib/lotu/cursor.rb', line 13 def update @x = $window.mouse_x @y = $window.mouse_y end |