Chromium Code Reviews

Unified Diff: sky/examples/game/lib/texture.dart

Issue 1204783003: Adds basic sprite sheet support to sprites (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: sky/examples/game/lib/texture.dart
diff --git a/sky/examples/game/lib/texture.dart b/sky/examples/game/lib/texture.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c8b75194c8db146c4e214d76956d2222164425cd
--- /dev/null
+++ b/sky/examples/game/lib/texture.dart
@@ -0,0 +1,40 @@
+part of sprites;
+
+class Texture {
+ final Image image;
+ Size _size;
jackson 2015/06/23 22:09:43 You might want to make this public and final inste
+ String _fileName;
jackson 2015/06/23 22:09:43 Ditto
+ bool _rotated;
jackson 2015/06/23 22:09:43 final?
+ bool _trimmed;
jackson 2015/06/23 22:09:43 final?
+
+ Rect _frame;
jackson 2015/06/23 22:09:43 Ditto
+ Rect _spriteSourceSize;
jackson 2015/06/23 22:09:43 Ditto
+
+ Point _pivot;
jackson 2015/06/23 22:09:43 final?
+
+ Texture(this.image) {
+ _size = new Size(image.width.toDouble(), image.height.toDouble());
jackson 2015/06/23 22:09:43 Usually it's good to initialize members after the
+ _trimmed = false;
+ _rotated = false;
+ _frame = new Rect.fromLTRB(0.0, 0.0, _size.width, _size.height);
+ _spriteSourceSize = new Rect.fromLTRB(0.0, 0.0, _size.width, _size.height);
+ _pivot = new Point(0.5, 0.5);
+ }
+
+ Texture._fromSpriteFrame(this.image, this._fileName, this._size, this._rotated, this._trimmed, this._frame,
+ this._spriteSourceSize, this._pivot) {
+ }
+
+ Size get size => _size;
+
+ String get fileName => _fileName;
+
+ Rect get frame => _frame;
+
+ Rect get spriteSourceSize => _spriteSourceSize;
+
+ Texture textureFromRect(Rect rect, Point offset, bool rotated) {
+ // TODO: Implement this
+ return null;
+ }
+}

Powered by Google App Engine