Skip to content

Commit c7e2562

Browse files
committed
Merge pull request phaserjs#1107 from gamedolphin/test
Fixed Point.rotate bug . Also added a little documentation for world wrap.
2 parents 1f3a909 + b25e2bd commit c7e2562

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/core/World.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Phaser.World.prototype.shutdown = function () {
107107
/**
108108
* This will take the given game object and check if its x/y coordinates fall outside of the world bounds.
109109
* If they do it will reposition the object to the opposite side of the world, creating a wrap-around effect.
110+
* If sprite has a P2 body then the body (sprite.body) should be passed as first parameter to the function.
110111
*
111112
* @method Phaser.World#wrap
112113
* @param {Phaser.Sprite|Phaser.Image|Phaser.TileSprite|Phaser.Text} sprite - The object you wish to wrap around the world bounds.

src/geom/Point.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,9 @@ Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) {
823823
distance = Math.sqrt(((x - a.x) * (x - a.x)) + ((y - a.y) * (y - a.y)));
824824
}
825825

826-
return a.setTo(x + distance * Math.cos(angle), y + distance * Math.sin(angle));
826+
var requiredAngle = angle + Math.atan2(a.y - y, a.x - x);
827+
828+
return a.setTo(x + distance * Math.cos(requiredAngle), y + distance * Math.sin(requiredAngle));
827829

828830
};
829831

0 commit comments

Comments
 (0)