summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--starling/node-2d.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/starling/node-2d.scm b/starling/node-2d.scm
index ccbb17b..8e3cad6 100644
--- a/starling/node-2d.scm
+++ b/starling/node-2d.scm
@@ -21,6 +21,7 @@
;;; Code:
(define-module (starling node-2d)
+ #:use-module (chickadee math bezier)
#:use-module (chickadee math easings)
#:use-module (chickadee math matrix)
#:use-module (chickadee math rect)
@@ -67,6 +68,7 @@
rotate-to
scale-by
scale-to
+ follow-bezier-path
<sprite>
texture
@@ -349,6 +351,22 @@
(define-method (scale-by (node <node-2d>) dsx dsy duration)
(scale-by node dsx dsy duration smoothstep))
+(define-method (follow-bezier-path (node <node-2d>) path duration forward?)
+ (let ((p (position node))
+ (path (if forward? path (reverse path))))
+ (for-each (lambda (bezier)
+ (tween duration
+ (if forward? 0.0 1.0)
+ (if forward? 1.0 0.0)
+ (lambda (t)
+ (bezier-curve-point-at! p bezier t)
+ (dirty! node))
+ #:ease linear))
+ path)))
+
+(define-method (follow-bezier-path (node <node-2d>) path duration)
+ (follow-bezier-path node path duration #t))
+
;; Events
(define-method (update* (node <node-2d>) dt)