summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2022-10-10 11:28:18 -0400
committerDavid Thompson <dthompson2@worcester.edu>2022-10-10 11:28:18 -0400
commitdcf869ccd7ec9d33c937507fe96e9e09f517bded (patch)
tree394197a71d2977d4977362cdf1a388bc456df824
parent5d994cab2d3400e9fbbc08d95043745cca70602b (diff)
Fix initial bounding box bug for altas/animated sprites.HEADmaster
-rw-r--r--starling/node-2d.scm13
1 files changed, 10 insertions, 3 deletions
diff --git a/starling/node-2d.scm b/starling/node-2d.scm
index 54d4793..50a4951 100644
--- a/starling/node-2d.scm
+++ b/starling/node-2d.scm
@@ -703,10 +703,14 @@
#:init-form blend:alpha))
(define-method (default-width (sprite <sprite>))
- (texture-width (texture sprite)))
+ (if (slot-bound? sprite 'texture)
+ (texture-width (texture sprite))
+ 0))
(define-method (default-height (sprite <sprite>))
- (texture-height (texture sprite)))
+ (if (slot-bound? sprite 'texture)
+ (texture-height (texture sprite))
+ 0))
(define-method (render (sprite <sprite>) alpha)
(let ((t (texture sprite)))
@@ -725,7 +729,10 @@
(index #:accessor index #:init-keyword #:index #:init-value 0 #:watch? #t))
(define-method (sync-texture (sprite <atlas-sprite>))
- (set! (texture sprite) (texture-atlas-ref (atlas sprite) (index sprite))))
+ (let ((t (texture-atlas-ref (atlas sprite) (index sprite))))
+ (set! (texture sprite) t)
+ (set! (width sprite) (texture-width t))
+ (set! (height sprite) (texture-height t))))
(define-method (on-boot (sprite <atlas-sprite>))
(sync-texture sprite))