|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | var Bodies = require('./lib/factory/Bodies'); |
| 8 | +var Body = require('./lib/body/Body'); |
8 | 9 | var Class = require('../../utils/Class'); |
9 | 10 | var Composites = require('./lib/factory/Composites'); |
10 | 11 | var Constraint = require('./lib/constraint/Constraint'); |
@@ -607,6 +608,65 @@ var Factory = new Class({ |
607 | 608 | return MatterGameObject(this.world, gameObject, options); |
608 | 609 | }, |
609 | 610 |
|
| 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 | + |
610 | 670 | /** |
611 | 671 | * Destroys this Factory. |
612 | 672 | * |
|
0 commit comments