~lthms/fairy.lisp

ba2d8658376687200af462766c49aa63e94d24eb — Thomas Letan 4 years ago 09f96cf
feature: Reorder elements of a layers with :sort-with
1 files changed, 10 insertions(+), 1 deletions(-)

M fairy.lisp
M fairy.lisp => fairy.lisp +10 -1
@@ 32,6 32,7 @@
           height

           layer
           sort-with
           boundary
           add-child
           get-child


@@ 132,7 133,10 @@
             :accessor children)
   (boundary :initarg :boundary
             :initform nil
             :accessor boundary)))
             :accessor boundary)
   (sort-with :initarg :sort-with
              :initform nil
              :accessor sort-with)))

(defdraw (el layer)
    (with-slots (boundary children) el


@@ 155,6 159,11 @@
        value))

(defmethod update ((el layer) dt)
  (when (sort-with el)
    (sort (children el)
          (sort-with el)
          :key #'cdr))

  (dolist (e (children el))
    (update (cdr e) dt))
  (call-next-method))