Module: ShatteredState::Actor::ClassMethods

Defined in:
lib/shattered_state/actor/actor.rb

Instance Method Summary collapse

Instance Method Details

#actor(name, options = {}) ⇒ Object

An actor is the MVC encapsulated into one object.

Here is how it works: You specify a actor in a game state with some starting attributes:

class BattleState
  actor :player
  actor :bullet, :target => :player
end

With a model BulletModel defined as:

class BulletModel
  attr_writer :target
end

And our BulletModel will be created, with the target set to the player object.

Setting values for the actors is done prior to initialization, so:

class BulletModel
  attr_writer :target
  def initialize
    target.run_away_from(self)
  end
end

Works fine.

Actors delegate to ShatteredState::Base objects, and controllers delegate to Model and View.

See ShatteredState::Base for more detail.



40
41
42
# File 'lib/shattered_state/actor/actor.rb', line 40

def actor( name, options = {} )
  before_init_call( :actor, name, options, true )
end