Class: Phaser::Game

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

Instance Method Summary collapse

Constructor Details

#initialize(arg_hash = {}, &block) ⇒ Game

Returns a new instance of Game.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/opal/phaser/core/game.rb', line 21

def initialize(arg_hash = {}, &block)

  width       = arg_hash.fetch(:width) { 800 }
  height      = arg_hash.fetch(:height) { 600 }
  renderer    = arg_hash.fetch(:renderer) { Phaser::AUTO }
  parent      = arg_hash.fetch(:parent) { "" }
  state       = arg_hash.fetch(:state) { nil }
  transparent = arg_hash.fetch(:transparent) { false }
  antialias   = arg_hash.fetch(:antialias) { true }
  physics     = arg_hash.fetch(:physics) { nil }

  if state
    state.game = self
  end

  if block_given?
    state = State.new(self) if state.nil?
    state.instance_eval(&block)
  end

  @native = %x{
    new Phaser.Game(width, height, renderer, parent, #{state.to_n}, transparent,
                    antialias, physics)
  }
end

Instance Method Details

#paused=(bool) ⇒ Object



70
71
72
# File 'lib/opal/phaser/core/game.rb', line 70

def paused=(bool)
  `#@native.paused = bool`
end

#timeObject



66
67
68
# File 'lib/opal/phaser/core/game.rb', line 66

def time
  Phaser::Time.new(`#@native.time`)
end