Sha256: d749ef0f65195b5ca40d87ba119b140557273de8bcd933924fe8ba660f7be66e

Contents?: true

Size: 416 Bytes

Versions: 2

Compression:

Stored size: 416 Bytes

Contents

define_behavior :positioned do
  requires :director
  setup do
    actor.has_attributes x: 0, y: 0
    director.when :update do |time|
      if @x_dirty || @y_dirty
        actor.react_to :position_changed
        actor.emit :position_changed 
      end
      @x_dirty = false
      @y_dirty = false
    end
    actor.when :x_changed do @x_dirty = true end
    actor.when :y_changed do @y_dirty = true end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gamebox-0.4.0.rc2 lib/gamebox/behaviors/positioned.rb
gamebox-0.4.0.rc1 lib/gamebox/behaviors/positioned.rb