Index: sky/examples/game/lib/spritesheet.dart |
diff --git a/sky/examples/game/lib/spritesheet.dart b/sky/examples/game/lib/spritesheet.dart |
index 57d84883fe229d1ae4b8625e8a991685b920fd46..39bf503a28808d2883d9e8c3a096ab9b6996aad6 100644 |
--- a/sky/examples/game/lib/spritesheet.dart |
+++ b/sky/examples/game/lib/spritesheet.dart |
@@ -1,10 +1,19 @@ |
part of sprites; |
+/// A sprite sheet packs a number of smaller images into a single large image. |
+/// |
+/// The placement of the smaller images are defined by a json file. The larger image and json file is typically created |
+/// by a tool such as TexturePacker. The [SpriteSheet] class will take a reference to a larger image and a json string. |
+/// From the image and the string the [SpriteSheet] creates a number of [Texture] objects. The names of the frames in |
+/// the sprite sheet definition are used to reference the different textures. |
class SpriteSheet { |
Image _image; |
Map<String, Texture> _textures = new Map(); |
+ /// Creates a new sprite sheet from an [_image] and a sprite sheet [jsonDefinition]. |
+ /// |
+ /// var mySpriteSheet = new SpriteSheet(myImage, jsonString); |
SpriteSheet(this._image, String jsonDefinition) { |
assert(_image != null); |
assert(jsonDefinition != null); |
@@ -53,7 +62,13 @@ class SpriteSheet { |
return new Point(x.toDouble(), y.toDouble()); |
} |
+ /// The image used by the sprite sheet. |
+ /// |
+ /// var spriteSheetImage = mySpriteSheet.image; |
Image get image => _image; |
+ /// Returns a texture by its name. |
+ /// |
+ /// var myTexture = mySpriteSheet["example.png"]; |
Texture operator [](String fileName) => _textures[fileName]; |
} |