summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/render/tiled.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/chickadee/render/tiled.scm b/chickadee/render/tiled.scm
index 23c68d9..802a9a2 100644
--- a/chickadee/render/tiled.scm
+++ b/chickadee/render/tiled.scm
@@ -46,6 +46,7 @@
tile-map-layers
tile-map-properties
tile-map-rect
+ tile-map-layer-ref
animation-frame?
animation-frame-tile
@@ -174,6 +175,22 @@
(shape map-object-shape)
(properties map-object-properties))
+(define (tile-map-layer-ref tile-map name)
+ "Return the layer named NAME."
+ (define (layer-name layer)
+ (if (tile-layer? layer)
+ (tile-layer-name layer)
+ (object-layer-name layer)))
+ (let ((layers (tile-map-layers tile-map)))
+ (let loop ((i 0))
+ (cond
+ ((= i (vector-length layers))
+ #f)
+ ((string=? name (layer-name (vector-ref layers i)))
+ (vector-ref layers i))
+ (else
+ (loop (+ i 1)))))))
+
(define (load-tile-map file-name)
"Load the Tiled TMX formatted map in FILE-NAME."
(define map-directory