| Index: sky/examples/game/lib/sprite.dart
|
| diff --git a/sky/examples/game/lib/sprite.dart b/sky/examples/game/lib/sprite.dart
|
| index 22ddbee237558f96985707f8af4ca995c3b16160..6202e20e30b4abced89a1f19f36f9fe7311b3145 100644
|
| --- a/sky/examples/game/lib/sprite.dart
|
| +++ b/sky/examples/game/lib/sprite.dart
|
| @@ -103,11 +103,26 @@ class Sprite extends NodeWithSize {
|
| }
|
|
|
| // Do actual drawing of the sprite
|
| - canvas.drawImageRect(texture.image, texture.frame, texture.spriteSourceSize, paint);
|
| + if (texture.rotated) {
|
| + // Calculate the rotated frame and spriteSourceSize
|
| + Size originalFrameSize = texture.frame.size;
|
| + Rect rotatedFrame = new Rect.fromPointAndSize(texture.frame.upperLeft, new Size(originalFrameSize.height, originalFrameSize.width));
|
| + Point rotatedSpriteSourcePoint = new Point(
|
| + -texture.spriteSourceSize.top - (texture.spriteSourceSize.bottom - texture.spriteSourceSize.top),
|
| + texture.spriteSourceSize.left);
|
| + Rect rotatedSpriteSourceSize = new Rect.fromPointAndSize(rotatedSpriteSourcePoint, new Size(originalFrameSize.height, originalFrameSize.width));
|
| +
|
| + // Draw the rotated sprite
|
| + canvas.rotate(-Math.PI/2.0);
|
| + canvas.drawImageRect(texture.image, rotatedFrame, rotatedSpriteSourceSize, paint);
|
| + } else {
|
| + // Draw the sprite
|
| + canvas.drawImageRect(texture.image, texture.frame, texture.spriteSourceSize, paint);
|
| + }
|
| } else {
|
| // Paint a red square for missing texture
|
| canvas.drawRect(new Rect.fromLTRB(0.0, 0.0, size.width, size.height),
|
| - new Paint()..color = const Color.fromARGB(255, 255, 0, 0));
|
| + new Paint()..color = const Color.fromARGB(255, 255, 0, 0));
|
| }
|
| canvas.restore();
|
| }
|
|
|