summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-04-14 21:08:47 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-04-14 21:13:30 -0400
commit7da34ac08a9bb54732857bc7e12b12f873ccfe63 (patch)
tree3e6df7b5c76d662dc3925940d4e98a4d8a0c579e
parent773a0ab4cc8ce76fa8ea4c819c34033960436f76 (diff)
node-2d: Improve sprite texture state management.
-rw-r--r--starling/node-2d.scm12
1 files 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 @@
<sprite>
texture
- texcoords
source-rect
blend-mode
tint
@@ -573,7 +572,7 @@
;;;
(define-class <sprite> (<node-2d>)
- (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 <atlas-sprite>))
(set! (texture sprite) (texture-atlas-ref (atlas sprite) (index sprite))))
-(define-method (initialize (sprite <atlas-sprite>) initargs)
- (next-method)
+(define-method (on-boot (sprite <atlas-sprite>))
(sync-texture sprite))
(define-method (on-change (sprite <atlas-sprite>) slot-name old new)
- (sync-texture sprite))
+ (case slot-name
+ ((atlas index)
+ (sync-texture sprite))
+ (else
+ (next-method))))
;;;