This commit is contained in:
Richard Davey 2019-05-22 19:19:36 +01:00
commit 8e4632fb51
4 changed files with 82 additions and 4 deletions

View file

@ -2,6 +2,12 @@
## Version 3.18.0 - Raphtalia - in dev
### New Features
* `Matter.Factory.velocity` is a new method that allows you to set the velocity on a Matter Body directly.
* `Matter.Factory.angularVelocity` is a new method that allows you to set the angular velocity on a Matter Body directly.
* `Matter.Factory.force` is a new method that allows you to apply a force from a world position on a Matter Body directly.
### Updates
* `Zones` will now use the new `customHitArea` property introduced in 3.17 to avoid their hit areas from being resized if you specified your own custom hit area (thanks @rexrainbow)

View file

@ -5,6 +5,7 @@
*/
var Bodies = require('./lib/factory/Bodies');
var Body = require('./lib/body/Body');
var Class = require('../../utils/Class');
var Composites = require('./lib/factory/Composites');
var Constraint = require('./lib/constraint/Constraint');
@ -607,6 +608,65 @@ var Factory = new Class({
return MatterGameObject(this.world, gameObject, options);
},
/**
* Instantly sets the linear velocity of the given body. Position, angle, force etc. are unchanged.
*
* See also `force`.
*
* @method Phaser.Physics.Matter.Factory#velocity
* @since 3.18.0
*
* @param {MatterJS.Body} body - The Matter Body to set the velocity on.
* @param {Phaser.Types.Math.Vector2Like} velocity - The velocity to set. An object with public `x` and `y` components.
*
* @return {MatterJS.Body} The Matter body.
*/
velocity: function (body, velocity)
{
Body.setVelocity(body, velocity);
return body;
},
/**
* Instantly sets the angular velocity of the given body. Position, angle, force etc. are unchanged.
*
* See also `force`.
*
* @method Phaser.Physics.Matter.Factory#angularVelocity
* @since 3.18.0
*
* @param {MatterJS.Body} body - The Matter Body to set the velocity on.
* @param {number} velocity - The angular velocity to set.
*
* @return {MatterJS.Body} The Matter body.
*/
angularVelocity: function (body, velocity)
{
Body.setAngularVelocity(body, velocity);
return body;
},
/**
* Applies a force to a body from a given world-space position, including resulting torque.
*
* @method Phaser.Physics.Matter.Factory#force
* @since 3.18.0
*
* @param {MatterJS.Body} body - The Matter Body to set the force on.
* @param {Phaser.Types.Math.Vector2Like} position - The world position to apply the force from. An object with public `x` and `y` components.
* @param {Phaser.Types.Math.Vector2Like} force - The force to set. An object with public `x` and `y` components.
*
* @return {MatterJS.Body} The Matter body.
*/
force: function (body, position, force)
{
Body.applyForce(body, position, force);
return body;
},
/**
* Destroys this Factory.
*

View file

@ -4,6 +4,7 @@
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Body = require('./lib/body/Body');
var Class = require('../../utils/Class');
var Factory = require('./Factory');
var GetFastValue = require('../../utils/object/GetFastValue');
@ -91,6 +92,15 @@ var MatterPhysics = new Class({
*/
this.verts = Vertices;
/**
* A reference to the `Matter.Body` module which contains methods for creating and manipulating body models.
*
* @name Phaser.Physics.Matter.MatterPhysics#body
* @type {MatterJS.Body}
* @since 3.18.0
*/
this.body = Body;
// Matter plugins
if (GetValue(this.config, 'plugins.attractors', false))

View file

@ -1203,13 +1203,15 @@ var ScaleManager = new Class({
{
if (fullscreen.keyboard)
{
// eslint-disable-next-line es5/no-arrow-functions
fsTarget[fullscreen.request](Element.ALLOW_KEYBOARD_INPUT).then(() => this.fullscreenSuccessHandler()).catch((error) => this.fullscreenErrorHandler(error));
fsTarget[fullscreen.request](Element.ALLOW_KEYBOARD_INPUT)
.then(this.fullscreenSuccessHandler)
.catch(this.fullscreenErrorHandler);
}
else
{
// eslint-disable-next-line es5/no-arrow-functions
fsTarget[fullscreen.request](fullscreenOptions).then(() => this.fullscreenSuccessHandler()).catch((error) => this.fullscreenErrorHandler(error));
fsTarget[fullscreen.request](fullscreenOptions)
.then(this.fullscreenSuccessHandler)
.catch(this.fullscreenErrorHandler);
}
}
else