Module: UserInputs

Included in:
Actor, Shape
Defined in:
lib/fantasy/includes/user_inputs.rb

Instance Method Summary collapse

Instance Method Details

#on_click(&block) ⇒ Object



29
30
31
# File 'lib/fantasy/includes/user_inputs.rb', line 29

def on_click(&block)
  @on_click_callback = block
end

#on_click_doObject



58
59
60
61
# File 'lib/fantasy/includes/user_inputs.rb', line 58

def on_click_do
  puts "XXX: on_click_do: #{@on_click_callback}"
  instance_exec(&@on_click_callback) unless @on_click_callback.nil?
end

#on_cursor_down(&block) ⇒ Object

Set callbacks



5
6
7
# File 'lib/fantasy/includes/user_inputs.rb', line 5

def on_cursor_down(&block)
  @on_cursor_down_callback = block
end

#on_cursor_down_doObject

Execute callbacks



34
35
36
# File 'lib/fantasy/includes/user_inputs.rb', line 34

def on_cursor_down_do
  instance_exec(&@on_cursor_down_callback) unless @on_cursor_down_callback.nil?
end

#on_cursor_left(&block) ⇒ Object



13
14
15
# File 'lib/fantasy/includes/user_inputs.rb', line 13

def on_cursor_left(&block)
  @on_cursor_left_callback = block
end

#on_cursor_left_doObject



42
43
44
# File 'lib/fantasy/includes/user_inputs.rb', line 42

def on_cursor_left_do
  instance_exec(&@on_cursor_left_callback) unless @on_cursor_left_callback.nil?
end

#on_cursor_right(&block) ⇒ Object



17
18
19
# File 'lib/fantasy/includes/user_inputs.rb', line 17

def on_cursor_right(&block)
  @on_cursor_right_callback = block
end

#on_cursor_right_doObject



46
47
48
# File 'lib/fantasy/includes/user_inputs.rb', line 46

def on_cursor_right_do
  instance_exec(&@on_cursor_right_callback) unless @on_cursor_right_callback.nil?
end

#on_cursor_up(&block) ⇒ Object



9
10
11
# File 'lib/fantasy/includes/user_inputs.rb', line 9

def on_cursor_up(&block)
  @on_cursor_up_callback = block
end

#on_cursor_up_doObject



38
39
40
# File 'lib/fantasy/includes/user_inputs.rb', line 38

def on_cursor_up_do
  instance_exec(&@on_cursor_up_callback) unless @on_cursor_up_callback.nil?
end

#on_mouse_button_left(&block) ⇒ Object



25
26
27
# File 'lib/fantasy/includes/user_inputs.rb', line 25

def on_mouse_button_left(&block)
  @on_mouse_button_left_callback = block
end

#on_mouse_button_left_doObject



54
55
56
# File 'lib/fantasy/includes/user_inputs.rb', line 54

def on_mouse_button_left_do
  instance_exec(&@on_mouse_button_left_callback) unless @on_mouse_button_left_callback.nil?
end

#on_space_bar(&block) ⇒ Object



21
22
23
# File 'lib/fantasy/includes/user_inputs.rb', line 21

def on_space_bar(&block)
  @on_space_bar_callback = block
end

#on_space_bar_doObject



50
51
52
# File 'lib/fantasy/includes/user_inputs.rb', line 50

def on_space_bar_do
  instance_exec(&@on_space_bar_callback) unless @on_space_bar_callback.nil?
end