Class: Phaser::Tween

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

Instance Method Summary collapse

Instance Method Details

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



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/opal/phaser/tween/tween.rb', line 19

def on(type, context = nil, &block)
  case type.to_sym
  when :child_complete
    `#@native.onChildComplete.add(#{block.to_n}, #{context})`
  when :complete
    `#@native.onComplete.add(#{block.to_n}, #{context})`
  when :loop
    `#@native.onLoop.add(#{block.to_n}, #{context})`
  when :repeat
    `#@native.onRepeat.add(#{block.to_n}, #{context})`
  when start
    `#@native.onStart.add(#{block.to_n}, #{context})`
  end
end

#to(args = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/opal/phaser/tween/tween.rb', line 7

def to(args = {})
  optional_args = {duration: 1000, ease: Phaser::Easing.Default, auto_start: false, delay: 0, repeat: 0, yoyo: false}

  optional_args.each do |name, default_value|
    unless args.include?(name)
      args[name] = default_value
    end
  end

  Tween.new `#@native.to(#{args[:properties].to_n}, #{args[:duration]}, #{args[:ease]}, #{args[:auto_start]}, #{args[:delay]}, #{args[:repeat]}, #{args[:yoyo]})`
end