2015-03-01 07:00:17 +00:00
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2015 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Delta component provides access to delta values between the Game Objects current and previous position.
|
2015-03-01 07:00:17 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
*/
|
2015-02-17 05:15:04 +00:00
|
|
|
Phaser.Component.Delta = function () {};
|
|
|
|
|
|
|
|
Phaser.Component.Delta.prototype = {
|
|
|
|
|
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* Returns the delta x value. The difference between world.x now and in the previous frame.
|
|
|
|
*
|
|
|
|
* The value will be positive if the Game Object has moved to the right or negative if to the left.
|
2015-02-17 05:15:04 +00:00
|
|
|
*
|
2015-03-23 23:27:14 +00:00
|
|
|
* @property {number} deltaX
|
2015-02-17 05:15:04 +00:00
|
|
|
* @readonly
|
|
|
|
*/
|
|
|
|
deltaX: {
|
|
|
|
|
|
|
|
get: function() {
|
|
|
|
|
|
|
|
return this.world.x - this.previousPosition.x;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* Returns the delta y value. The difference between world.y now and in the previous frame.
|
|
|
|
*
|
|
|
|
* The value will be positive if the Game Object has moved down or negative if up.
|
2015-02-17 05:15:04 +00:00
|
|
|
*
|
2015-03-23 23:27:14 +00:00
|
|
|
* @property {number} deltaY
|
2015-02-17 05:15:04 +00:00
|
|
|
* @readonly
|
|
|
|
*/
|
|
|
|
deltaY: {
|
|
|
|
|
|
|
|
get: function() {
|
|
|
|
|
|
|
|
return this.world.y - this.previousPosition.y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2015-03-23 23:27:14 +00:00
|
|
|
* Returns the delta z value. The difference between rotation now and in the previous frame.
|
2015-02-17 05:15:04 +00:00
|
|
|
*
|
|
|
|
* @property {number} deltaZ - The delta value.
|
|
|
|
* @readonly
|
|
|
|
*/
|
|
|
|
deltaZ: {
|
|
|
|
|
|
|
|
get: function() {
|
|
|
|
|
|
|
|
return this.rotation - this.previousRotation;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|