Class: Phaser::Input

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

Instance Method Summary collapse

Instance Method Details

#on(type, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/opal/phaser/input/input.rb', line 15

def on(type, &block)
  if block_given?
    case type.to_sym
    when :down
      `#@native.onDown.add(#{block.to_n})`
    when :up
      `#@native.onUp.add(#{block.to_n})`
    when :tap
      `#@native.onTap.add(#{block.to_n})`
    when :hold
      `#@native.onHold.add(#{block.to_n})`
    end
  else
    Signal.new
  end
end