lib/gamebox/behaviors/layered.rb in gamebox-0.3.4 vs lib/gamebox/behaviors/layered.rb in gamebox-0.4.0.rc1
- old
+ new
@@ -1,34 +1,21 @@
# Keeps track of the layer that something is to be drawn on.
# By default it sets everything to layer 0 and parallax layer of
# 1.
-class Layered < Behavior
+Behavior.define :layered do
- attr_accessor :layer, :parallax
- def setup
+ setup do
if @opts.is_a? Hash
- @layer = @opts[:layer]
- @parallax = @opts[:parallax]
+ layer = @opts[:layer]
+ parallax = @opts[:parallax]
else
- @layer = @opts
+ layer = @opts
end
- @layer ||= 0
- @parallax ||= 1
+ layer ||= 0
+ parallax ||= 1
- relegates :layer=, :layer, :parallax=, :parallax,
- :layered
+ actor.has_attributes layer: layer, parallax: parallax
end
- def layered
- self
- end
-
- def parallax=(new_parallax)
- @parallax = new_parallax
- end
-
- def layer=(new_layer)
- @layer = new_layer
- end
end