From 7da34ac08a9bb54732857bc7e12b12f873ccfe63 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 14 Apr 2021 21:08:47 -0400 Subject: node-2d: Improve sprite texture state management. --- starling/node-2d.scm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/starling/node-2d.scm b/starling/node-2d.scm index 00d909a..f439ebe 100644 --- a/starling/node-2d.scm +++ b/starling/node-2d.scm @@ -92,7 +92,6 @@ texture - texcoords source-rect blend-mode tint @@ -573,7 +572,7 @@ ;;; (define-class () - (texture #:accessor texture #:init-keyword #:texture #:asset? #t) + (texture #:accessor texture #:init-keyword #:texture #:asset? #t #:watch? #t) (batch #:accessor batch #:init-keyword #:batch #:init-form #f) @@ -630,12 +629,15 @@ (define-method (sync-texture (sprite )) (set! (texture sprite) (texture-atlas-ref (atlas sprite) (index sprite)))) -(define-method (initialize (sprite ) initargs) - (next-method) +(define-method (on-boot (sprite )) (sync-texture sprite)) (define-method (on-change (sprite ) slot-name old new) - (sync-texture sprite)) + (case slot-name + ((atlas index) + (sync-texture sprite)) + (else + (next-method)))) ;;; -- cgit v1.2.3