2015-03-01 07:00:17 +00:00
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2016-04-04 21:15:01 +00:00
|
|
|
* @copyright 2016 Photon Storm Ltd.
|
2015-03-23 23:27:14 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Angle Component provides access to an `angle` property; the rotation of a Game Object in degrees.
|
2015-03-01 07:00:17 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
*/
|
2015-02-17 05:15:04 +00:00
|
|
|
Phaser.Component.Angle = function () {};
|
|
|
|
|
|
|
|
Phaser.Component.Angle.prototype = {
|
|
|
|
|
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* The angle property is the rotation of the Game Object in *degrees* from its original orientation.
|
|
|
|
*
|
|
|
|
* Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
|
|
|
|
*
|
|
|
|
* Values outside this range are added to or subtracted from 360 to obtain a value within the range.
|
|
|
|
* For example, the statement player.angle = 450 is the same as player.angle = 90.
|
|
|
|
*
|
|
|
|
* If you wish to work in radians instead of degrees you can use the property `rotation` instead.
|
|
|
|
* Working in radians is slightly faster as it doesn't have to perform any calculations.
|
2015-02-17 05:15:04 +00:00
|
|
|
*
|
2015-03-23 23:27:14 +00:00
|
|
|
* @property {number} angle
|
2015-02-17 05:15:04 +00:00
|
|
|
*/
|
|
|
|
angle: {
|
|
|
|
|
|
|
|
get: function() {
|
|
|
|
|
|
|
|
return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation));
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function(value) {
|
|
|
|
|
|
|
|
this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|