Class: Phaser::State
- Inherits:
-
Object
- Object
- Phaser::State
- Defined in:
- lib/opal/phaser/core/state.rb
Instance Attribute Summary collapse
-
#game ⇒ Object
writeonly
Sets the attribute game.
Instance Method Summary collapse
- #create(&block) ⇒ Object
-
#initialize(game = nil, &block) ⇒ State
constructor
A new instance of State.
- #preload(&block) ⇒ Object
- #render(&block) ⇒ Object
- #to_n ⇒ Object
- #update(&block) ⇒ Object
Constructor Details
#initialize(game = nil, &block) ⇒ State
Returns a new instance of State.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/opal/phaser/core/state.rb', line 4 def initialize(game = nil, &block) @game = game @native = %x{ new Phaser.State() } @preload = proc {} @create = proc {} @update = proc {} @render = proc {} if block_given? instance_eval(&block) end end |
Instance Attribute Details
#game=(value) ⇒ Object (writeonly)
Sets the attribute game
3 4 5 |
# File 'lib/opal/phaser/core/state.rb', line 3 def game=(value) @game = value end |
Instance Method Details
#create(&block) ⇒ Object
23 24 25 |
# File 'lib/opal/phaser/core/state.rb', line 23 def create(&block) @create = proc { block.call(@game) } end |
#preload(&block) ⇒ Object
19 20 21 |
# File 'lib/opal/phaser/core/state.rb', line 19 def preload(&block) @preload = proc { block.call(@game) } end |
#render(&block) ⇒ Object
31 32 33 |
# File 'lib/opal/phaser/core/state.rb', line 31 def render(&block) @render = proc { block.call(@game) } end |
#to_n ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/opal/phaser/core/state.rb', line 35 def to_n %x{ var obj = { preload: #@preload, create: #@create } } return %x{ obj } end |
#update(&block) ⇒ Object
27 28 29 |
# File 'lib/opal/phaser/core/state.rb', line 27 def update(&block) @update = proc { block.call(@game) } end |