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.



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

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

#is_booted?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/opal/phaser/core/game.rb', line 86

def is_booted?
  `#@native.isBooted`
end

#paused=(bool) ⇒ Object



74
75
76
# File 'lib/opal/phaser/core/game.rb', line 74

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

#rendererObject



78
79
80
81
82
83
84
# File 'lib/opal/phaser/core/game.rb', line 78

def renderer
  if `#@native.renderer instanceof PIXI.WebGLRenderer`
    PIXI::WebGLRenderer.new(`#@native.renderer`)
  else
    PIXI::CanvasRenderer.new(`#@native.renderer`)
  end
end

#timeObject



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

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