From aeb013df855052aec8a5199f82d9725be6d99c1b Mon Sep 17 00:00:00 2001 From: Boutade Date: Fri, 18 Oct 2019 12:08:52 -0500 Subject: checking for completes in a sequence --- animise.lisp | 9 ++++++++- package.lisp | 3 ++- tweening.lisp | 4 ++++ 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 -- cgit v1.2.3