Skip to content

Commit 8e4632f

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents d2dac14 + d7af904 commit 8e4632f

4 files changed

Lines changed: 82 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Version 3.18.0 - Raphtalia - in dev
44

5+
### New Features
6+
7+
* `Matter.Factory.velocity` is a new method that allows you to set the velocity on a Matter Body directly.
8+
* `Matter.Factory.angularVelocity` is a new method that allows you to set the angular velocity on a Matter Body directly.
9+
* `Matter.Factory.force` is a new method that allows you to apply a force from a world position on a Matter Body directly.
10+
511
### Updates
612

713
* `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)

src/physics/matter-js/Factory.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
var Bodies = require('./lib/factory/Bodies');
8+
var Body = require('./lib/body/Body');
89
var Class = require('../../utils/Class');
910
var Composites = require('./lib/factory/Composites');
1011
var Constraint = require('./lib/constraint/Constraint');
@@ -607,6 +608,65 @@ var Factory = new Class({
607608
return MatterGameObject(this.world, gameObject, options);
608609
},
609610

611+
/**
612+
* Instantly sets the linear velocity of the given body. Position, angle, force etc. are unchanged.
613+
*
614+
* See also `force`.
615+
*
616+
* @method Phaser.Physics.Matter.Factory#velocity
617+
* @since 3.18.0
618+
*
619+
* @param {MatterJS.Body} body - The Matter Body to set the velocity on.
620+
* @param {Phaser.Types.Math.Vector2Like} velocity - The velocity to set. An object with public `x` and `y` components.
621+
*
622+
* @return {MatterJS.Body} The Matter body.
623+
*/
624+
velocity: function (body, velocity)
625+
{
626+
Body.setVelocity(body, velocity);
627+
628+
return body;
629+
},
630+
631+
/**
632+
* Instantly sets the angular velocity of the given body. Position, angle, force etc. are unchanged.
633+
*
634+
* See also `force`.
635+
*
636+
* @method Phaser.Physics.Matter.Factory#angularVelocity
637+
* @since 3.18.0
638+
*
639+
* @param {MatterJS.Body} body - The Matter Body to set the velocity on.
640+
* @param {number} velocity - The angular velocity to set.
641+
*
642+
* @return {MatterJS.Body} The Matter body.
643+
*/
644+
angularVelocity: function (body, velocity)
645+
{
646+
Body.setAngularVelocity(body, velocity);
647+
648+
return body;
649+
},
650+
651+
/**
652+
* Applies a force to a body from a given world-space position, including resulting torque.
653+
*
654+
* @method Phaser.Physics.Matter.Factory#force
655+
* @since 3.18.0
656+
*
657+
* @param {MatterJS.Body} body - The Matter Body to set the force on.
658+
* @param {Phaser.Types.Math.Vector2Like} position - The world position to apply the force from. An object with public `x` and `y` components.
659+
* @param {Phaser.Types.Math.Vector2Like} force - The force to set. An object with public `x` and `y` components.
660+
*
661+
* @return {MatterJS.Body} The Matter body.
662+
*/
663+
force: function (body, position, force)
664+
{
665+
Body.applyForce(body, position, force);
666+
667+
return body;
668+
},
669+
610670
/**
611671
* Destroys this Factory.
612672
*

src/physics/matter-js/MatterPhysics.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @license {@link https://opensource.org/licenses/MIT|MIT License}
55
*/
66

7+
var Body = require('./lib/body/Body');
78
var Class = require('../../utils/Class');
89
var Factory = require('./Factory');
910
var GetFastValue = require('../../utils/object/GetFastValue');
@@ -91,6 +92,15 @@ var MatterPhysics = new Class({
9192
*/
9293
this.verts = Vertices;
9394

95+
/**
96+
* A reference to the `Matter.Body` module which contains methods for creating and manipulating body models.
97+
*
98+
* @name Phaser.Physics.Matter.MatterPhysics#body
99+
* @type {MatterJS.Body}
100+
* @since 3.18.0
101+
*/
102+
this.body = Body;
103+
94104
// Matter plugins
95105

96106
if (GetValue(this.config, 'plugins.attractors', false))

src/scale/ScaleManager.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,13 +1203,15 @@ var ScaleManager = new Class({
12031203
{
12041204
if (fullscreen.keyboard)
12051205
{
1206-
// eslint-disable-next-line es5/no-arrow-functions
1207-
fsTarget[fullscreen.request](Element.ALLOW_KEYBOARD_INPUT).then(() => this.fullscreenSuccessHandler()).catch((error) => this.fullscreenErrorHandler(error));
1206+
fsTarget[fullscreen.request](Element.ALLOW_KEYBOARD_INPUT)
1207+
.then(this.fullscreenSuccessHandler)
1208+
.catch(this.fullscreenErrorHandler);
12081209
}
12091210
else
12101211
{
1211-
// eslint-disable-next-line es5/no-arrow-functions
1212-
fsTarget[fullscreen.request](fullscreenOptions).then(() => this.fullscreenSuccessHandler()).catch((error) => this.fullscreenErrorHandler(error));
1212+
fsTarget[fullscreen.request](fullscreenOptions)
1213+
.then(this.fullscreenSuccessHandler)
1214+
.catch(this.fullscreenErrorHandler);
12131215
}
12141216
}
12151217
else

0 commit comments

Comments
 (0)