   ([order update-fn]
    (assoc (group update-fn) :order order)))
 
-(defn scene []
+(defn new []
   (assoc (Scene.) :se-root (with-meta (group)  {:se-id :se-root})))
 
 (derive sprite/StaticImage ::sprite)

  (remove-child-id [this id]
    (update-in this [:children] disj id)))

(defrecord Scene []
  IScene
  (add [this element]
    (add this (keyword (gensym "se-")) element))
  (add [this id element]
    (add-to this :se-root id element))
  (add-to [this destination-id element]
    (add-to this destination-id (keyword (gensym "se-")) element))
  (add-to [this destination-id id element]
    (-> this
        (assoc id (with-meta element {:se-id id :parent destination-id}))

  (get-elements-at [this node-id]
    (get-elements this (get-children-ids (get-element this node-id)))))

(defn add!
  ([element]
   (update-scene! #(add % element)))
  ([id element]
     (update-scene! #(add % id element))))

(defn add-to!
  ([destination-id element]
   (update-scene! #(add-to % destination-id element)))
  ([destination-id id element]
   (update-scene! #(add-to % destination-id id element))))

(defn remove! [id]
  (update-scene! #(remove % id)))

(defn move-to! [id destination-id]
  (update-scene! #(move-to % id destination-id)))

(defn get-id [element]
  (:se-id (meta element)))

