Merge bundle into internal entities
This commit is contained in:
@@ -10,10 +10,12 @@
|
|||||||
(defn bundle
|
(defn bundle
|
||||||
"Returns an entity containing other entities. This is a useful way to keep
|
"Returns an entity containing other entities. This is a useful way to keep
|
||||||
related entities together. They will be drawn in the order they appear in the
|
related entities together. They will be drawn in the order they appear in the
|
||||||
internal :entities vector.
|
internal :entities vector. Any keys in the bundle, such as :x and :y, will
|
||||||
|
override the equivalent keys in each entity when being drawn.
|
||||||
|
|
||||||
(bundle (shape :filled) (texture \"image.png\"))
|
(bundle (shape :filled) (shape :line))
|
||||||
(assoc (bundle) :entities [])"
|
(assoc (bundle (shape :filled) (shape :line))
|
||||||
|
:x 100 :y 100)"
|
||||||
[& entities]
|
[& entities]
|
||||||
(BundleEntity. entities))
|
(BundleEntity. entities))
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,6 @@
|
|||||||
(.end object)))
|
(.end object)))
|
||||||
|
|
||||||
(defrecord BundleEntity [entities] Entity
|
(defrecord BundleEntity [entities] Entity
|
||||||
(draw-entity! [{:keys [entities]} screen batch]
|
(draw-entity! [{:keys [entities] :as entity} screen batch]
|
||||||
(doseq [e entities]
|
(doseq [e entities]
|
||||||
(draw-entity! e screen batch))))
|
(draw-entity! (merge e entity) screen batch))))
|
||||||
|
|||||||
Reference in New Issue
Block a user