Sha256: c4ef72874ec7504ac7b410ad4d098588f68e39019685dab73fdf5bf5106c3b42

Contents?: true

Size: 491 Bytes

Versions: 5

Compression:

Stored size: 491 Bytes

Contents

define_behavior :positioned do
  setup do
    x = opts[:x] || actor.do_or_do_not(:x) || 0
    y = opts[:y] || actor.do_or_do_not(:y) || 0
    actor.has_attributes position: vec2(x, y), x: x, y: y
    actor.when(:x_changed) { actor.position = vec2(actor.x, actor.y) }
    actor.when(:y_changed) { actor.position = vec2(actor.x, actor.y) }

    actor.when(:position_changed) do
      actor.update_attributes(
        x: actor.position.x,
        y: actor.position.y
      )
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gamebox-0.5.5 lib/gamebox/behaviors/positioned.rb
gamebox-0.5.4 lib/gamebox/behaviors/positioned.rb
gamebox-0.5.2 lib/gamebox/behaviors/positioned.rb
gamebox-0.5.1 lib/gamebox/behaviors/positioned.rb
gamebox-0.5.0 lib/gamebox/behaviors/positioned.rb