Class: Phaser::Events

Inherits:
Object
  • Object
show all
Includes:
Native
Defined in:
lib/opal/phaser/game_objects/events.rb

Instance Method Summary collapse

Instance Method Details

#on(type, context, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/opal/phaser/game_objects/events.rb', line 9

def on(type, context, &block)
  case type.to_sym
  when :up
    `#@native.onInputUp.add(#{block.to_n}, #{context})`
  when :down
    `#@native.onInputDown.add(#{block.to_n}, #{context})`
  when :out
    `#@native.onInputOut.add(#{block.to_n}, #{context})`
  when :over
    `#@native.onInputOver.add(#{block.to_n}, #{context})`
  when :out_of_bounds
    `#@native.onOutOfBounds.add(#{block.to_n}, #{context})`
  end
end