diff options
| author | jmoenig <jens@moenig.org> | 2013-08-08 13:59:59 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-08-08 13:59:59 +0200 |
| commit | 289dd6b2e69894546d47686cdadb8cc42aa6fd30 (patch) | |
| tree | f1bf0ee16587080e922427b68fe19639f2d07cee | |
| parent | 9bbd3795284bbd94e461b610f20645b02315098a (diff) | |
| download | snap-289dd6b2e69894546d47686cdadb8cc42aa6fd30.tar.gz snap-289dd6b2e69894546d47686cdadb8cc42aa6fd30.zip | |
Nested Sprite Rotation
| -rwxr-xr-x | history.txt | 1 | ||||
| -rw-r--r-- | objects.js | 15 |
2 files changed, 14 insertions, 2 deletions
diff --git a/history.txt b/history.txt index bfd8829..b13ecdf 100755 --- a/history.txt +++ b/history.txt @@ -1862,3 +1862,4 @@ ______ 130808 ------ * Objects: Nested Sprite Scaling +* Objects: Nested Sprite Rotation @@ -2693,11 +2693,22 @@ SpriteMorph.prototype.forward = function (steps) { SpriteMorph.prototype.setHeading = function (degrees) { var x = this.xPosition(), - y = this.yPosition(); + y = this.yPosition(), + turn = degrees - this.heading; + + // apply to myself this.changed(); SpriteMorph.uber.setHeading.call(this, degrees); - this.silentGotoXY(x, y); + this.silentGotoXY(x, y, true); // just me this.positionTalkBubble(); + + // propagate to my parts + this.parts.forEach(function (part) { + var pos = new Point(part.xPosition(), part.yPosition()), + trg = pos.rotateBy(radians(turn), new Point(x, y)); + part.turn(turn); + part.gotoXY(trg.x, trg.y); + }); }; SpriteMorph.prototype.faceToXY = function (x, y) { |
