summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--starling/node-2d.scm26
1 files changed, 23 insertions, 3 deletions
diff --git a/starling/node-2d.scm b/starling/node-2d.scm
index 663942c..cc0c85c 100644
--- a/starling/node-2d.scm
+++ b/starling/node-2d.scm
@@ -79,6 +79,8 @@
<sprite>
texture
+ texcoords
+ rect
blend-mode
tint
@@ -465,9 +467,15 @@
(define-generic texture)
+(define-method (texcoords (sprite <base-sprite>))
+ (texture-gl-tex-rect (asset-ref (texture sprite))))
+
+(define-method (rect (sprite <base-sprite>))
+ (texture-gl-rect (asset-ref (texture sprite))))
+
(define-method (render (sprite <base-sprite>) alpha)
(let* ((tex (asset-ref (texture sprite)))
- (rect (texture-gl-rect tex))
+ (rect (rect sprite))
(batch (batch sprite))
(tint (tint sprite))
(matrix (world-matrix sprite)))
@@ -475,7 +483,9 @@
(sprite-batch-add* batch rect matrix
#:tint tint
#:texture-region tex)
- (draw-sprite* tex rect matrix #:tint tint))))
+ (draw-sprite* tex rect matrix
+ #:tint tint
+ #:texcoords (texcoords sprite)))))
;;;
@@ -483,7 +493,17 @@
;;;
(define-class <sprite> (<base-sprite>)
- (texture #:accessor texture #:init-keyword #:texture))
+ (texture #:accessor texture #:init-keyword #:texture)
+ (texcoords #:init-keyword #:texcoords #:init-form #f)
+ (rect #:init-keyword #:rect #:init-form #f))
+
+(define-method (texcoords (sprite <sprite>))
+ (or (slot-ref sprite 'texcoords)
+ (next-method)))
+
+(define-method (rect (sprite <sprite>))
+ (or (slot-ref sprite 'rect)
+ (next-method)))
;;;