summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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))