summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoutade <thegoofist@protonmail.com>2019-10-18 12:08:52 -0500
committerBoutade <thegoofist@protonmail.com>2019-10-18 12:08:52 -0500
commitaeb013df855052aec8a5199f82d9725be6d99c1b (patch)
tree58da893961d92ae9db129566b192ae7936271d0a
parent23284accc56c71f3e293fc9ac0c923988ce4ab6a (diff)
checking for completes in a sequence
-rw-r--r--animise.lisp9
-rw-r--r--package.lisp3
-rw-r--r--tweening.lisp4
3 files changed, 14 insertions, 2 deletions
diff --git a/animise.lisp b/animise.lisp
index 232a6c1..4cb54ac 100644
--- a/animise.lisp
+++ b/animise.lisp
@@ -248,12 +248,19 @@
;; (reverse-tween seq)
;; (car (tweens seq)))))))
+(defun has-on-complete (thing)
+ (and (typep thing 'tween)
+ (on-complete thing)))
(defmethod run-tween ((ob tween-seq) time)
(let-when (tween (or
;; find the first unfinished tween in the sequence
(find-if-not (lambda (tween)
- (tween-finished-p tween time))
+ (when (tween-finished-p tween time)
+ (when (has-on-complete tween)
+ (funcall (on-complete tween))
+ (setf (on-complete tween) nil))
+ t))
(tweens ob))
;; otherwise apply any looping configuration on the sequence
;; and apply the tween that results
diff --git a/package.lisp b/package.lisp
index c8bc734..ae0361f 100644
--- a/package.lisp
+++ b/package.lisp
@@ -12,6 +12,7 @@
;; TWEEN PROTOCOL
#:start-time
+ #:on-complete
#:duration
#:loop-mode
#:run-tween
@@ -28,7 +29,7 @@
#:sequencing
#:pausing
#:grouping
-
+ #:take-action
;; EASING FUNCTIONS
#:bounce-out
diff --git a/tweening.lisp b/tweening.lisp
index df9b398..4de5c21 100644
--- a/tweening.lisp
+++ b/tweening.lisp
@@ -25,6 +25,10 @@
(setf (loop-mode ,this-seq) ',loop-mode)
,this-seq))))
+(defun take-action (action &key (delay 20) (at 0))
+ (let ((anim (pause delay at)))
+ (setf (on-complete anim) action)
+ anim))
(defun pausing (&key for at)
"A light wrapper around PAUSE. Is aware of default parameters that may have