From dcf869ccd7ec9d33c937507fe96e9e09f517bded Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 10 Oct 2022 11:28:18 -0400 Subject: Fix initial bounding box bug for altas/animated sprites. --- starling/node-2d.scm | 13 ++++++++++--- 1 file 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 )) - (texture-width (texture sprite))) + (if (slot-bound? sprite 'texture) + (texture-width (texture sprite)) + 0)) (define-method (default-height (sprite )) - (texture-height (texture sprite))) + (if (slot-bound? sprite 'texture) + (texture-height (texture sprite)) + 0)) (define-method (render (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 )) - (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 )) (sync-texture sprite)) -- cgit v1.2.3