phaser
Version:
A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.
95 lines (79 loc) • 2.18 kB
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 {number} value - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setAngularVelocity: function (value)
{
Body.setAngularVelocity(this.body, value);
return this;
},
/**
* [description]
*
* @method Phaser.Physics.Matter.Components.Velocity#setVelocityX
* @since 3.0.0
*
* @param {number} x - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
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 {number} y - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
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 {number} x - [description]
* @param {number} [y=x] - [description]
*
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setVelocity: function (x, y)
{
this._tempVec2.set(x, y);
Body.setVelocity(this.body, this._tempVec2);
return this;
}
};
module.exports = Velocity;