summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoutade <thegoofist@protonmail.com>2019-10-15 11:28:10 -0500
committerBoutade <thegoofist@protonmail.com>2019-10-15 11:28:10 -0500
commitb8776e6d3857d275cbb8b5983cb2f3b51eb44cb0 (patch)
tree87dbf4b152b90edc102fe5468ddcd565d0864ddc
parent595eddb6217483a85453425b2feaa257fbe5efa7 (diff)
added optional on-complete callback
-rw-r--r--animise.lisp11
1 files changed, 10 insertions, 1 deletions
diff --git a/animise.lisp b/animise.lisp
index 7103a0a..9f2eb0c 100644
--- a/animise.lisp
+++ b/animise.lisp
@@ -56,7 +56,11 @@
(setter)
(accessor
:initarg :accessor
- :initform (error "Must supply an accessor function"))))
+ :initform (error "Must supply an accessor function"))
+ (on-complete
+ :accessor on-complete
+ :initarg :on-complete
+ :initform nil)))
(defmethod initialize-instance :after ((tween tween) &key)
(with-slots (getter setter accessor) tween
@@ -151,6 +155,11 @@
(if rounding (round new-val) new-val)
target)))))
+(defmethod run-tween :after ((tween tween) time)
+ (when (and (on-complete tween) (tween-finished-p tween time))
+ (funcall (on-complete tween))
+ (setf (on-complete tween) nil)))
+
;;; Interface implementations for TWEEN-SEQ
(defmethod start-time ((ob tween-seq))