mirror of
https://github.com/photonstorm/phaser
synced 2024-11-14 00:47:29 +00:00
Line.rotate allows you to rotate a line by the given amount around its center point.
This commit is contained in:
parent
5f9bff0e8b
commit
732b80813e
4 changed files with 28 additions and 2 deletions
|
@ -307,6 +307,7 @@ Version 2.4 - "Katar" - in dev
|
|||
* Line.random will return a random point from anywhere on the Line segment.
|
||||
* Ellipse.random will return a uniformly distributed random point from anywhere within the ellipse.
|
||||
* Rectangle.random will return a uniformly distributed random point from anywhere within the rectangle.
|
||||
* Line.rotate allows you to rotate a line by the given amount around its center point.
|
||||
|
||||
### Updates
|
||||
|
||||
|
|
|
@ -102,6 +102,30 @@ Phaser.Line.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Rotates the line by the amount specified in `angle`.
|
||||
*
|
||||
* Rotation takes place from the center of the line.
|
||||
*
|
||||
* If you wish to rotate from either end see Line.start.rotate or Line.end.rotate.
|
||||
*
|
||||
* @method Phaser.Line#rotate
|
||||
* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the line by.
|
||||
* @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
|
||||
* @return {Phaser.Line} This line object
|
||||
*/
|
||||
rotate: function (angle, asDegrees) {
|
||||
|
||||
var x = this.start.x;
|
||||
var y = this.start.y;
|
||||
|
||||
this.start.rotate(this.end.x, this.end.y, angle, asDegrees, this.length);
|
||||
this.end.rotate(x, y, angle, asDegrees, this.length);
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks for intersection between this line and another Line.
|
||||
* If asSegment is true it will check for segment intersection. If asSegment is false it will check for line intersection.
|
||||
|
|
|
@ -308,7 +308,7 @@ Phaser.Point.prototype = {
|
|||
* @param {number} x - The x coordinate of the anchor point.
|
||||
* @param {number} y - The y coordinate of the anchor point.
|
||||
* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the Point to.
|
||||
* @param {boolean} asDegrees - Is the given rotation in radians (false) or degrees (true)?
|
||||
* @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
|
||||
* @param {number} [distance] - An optional distance constraint between the Point and the anchor.
|
||||
* @return {Phaser.Point} The modified point object.
|
||||
*/
|
||||
|
@ -797,7 +797,7 @@ Phaser.Point.normalize = function (a, out) {
|
|||
* @param {number} x - The x coordinate of the anchor point
|
||||
* @param {number} y - The y coordinate of the anchor point
|
||||
* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the Point by.
|
||||
* @param {boolean} [asDegrees=false] - Is the given angle to rotate by in radians (false) or degrees (true)?
|
||||
* @param {boolean} [asDegrees=false] - Is the given angle in radians (false) or degrees (true)?
|
||||
* @param {number} [distance] - An optional distance constraint between the Point and the anchor.
|
||||
* @return {Phaser.Point} The modified point object.
|
||||
*/
|
||||
|
|
1
typescript/phaser.d.ts
vendored
1
typescript/phaser.d.ts
vendored
|
@ -1988,6 +1988,7 @@ declare module Phaser {
|
|||
pointOnSegment(x: number, y: number): boolean;
|
||||
random(out?: Phaser.Point): Phaser.Point;
|
||||
reflect(line: Phaser.Line): number;
|
||||
rotate(angle: number, asDegrees?: boolean): Phaser.Line;
|
||||
setTo(x1?: number, y1?: number, x2?: number, y2?: number): Phaser.Line;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue