phaser/src/physics/matter-js/components/Velocity.js
2018-02-12 16:01:21 +00:00

94 lines
1.9 KiB
JavaScript

/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Body = require('../lib/body/Body');
/**
* [description]
*
* @name Phaser.Physics.Matter.Components.Velocity
* @since 3.0.0
*/
var Velocity = {
/**
* [description]
*
* @method Phaser.Physics.Matter.Components.Velocity#setAngularVelocity
* @since 3.0.0
*
* @param {[type]} value - [description]
*
* @return {[type]} [description]
*/
setAngularVelocity: function (value)
{
Body.setAngularVelocity(this.body, value);
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Matter.Components.Velocity#setVelocityX
* @since 3.0.0
*
* @param {[type]} x - [description]
*
* @return {[type]} [description]
*/
setVelocityX: function (x)
{
this._tempVec2.set(x, this.body.velocity.y);
Body.setVelocity(this.body, this._tempVec2);
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Matter.Components.Velocity#setVelocityY
* @since 3.0.0
*
* @param {[type]} y - [description]
*
* @return {[type]} [description]
*/
setVelocityY: function (y)
{
this._tempVec2.set(this.body.velocity.x, y);
Body.setVelocity(this.body, this._tempVec2);
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Matter.Components.Velocity#setVelocity
* @since 3.0.0
*
* @param {[type]} x - [description]
* @param {[type]} y - [description]
*
* @return {[type]} [description]
*/
setVelocity: function (x, y)
{
this._tempVec2.set(x, y);
Body.setVelocity(this.body, this._tempVec2);
return this;
}
};
module.exports = Velocity;