Sha256: 82c9fa472ff76cbda9ef6aea1c989cc31482aba978704a241554e5f06253fd25

Contents?: true

Size: 460 Bytes

Versions: 3

Compression:

Stored size: 460 Bytes

Contents

define_behavior :positioned do
  requires :director
  setup do
    x = opts[:x] || 0
    y = opts[:y] || 0
    actor.has_attributes x: x, y: y
    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

3 entries across 3 versions & 1 rubygems

Version Path
gamebox-0.4.0.rc5 lib/gamebox/behaviors/positioned.rb
gamebox-0.4.0.rc4 lib/gamebox/behaviors/positioned.rb
gamebox-0.4.0.rc3 lib/gamebox/behaviors/positioned.rb