Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/photonstorm/phaser
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Oct 26, 2023
2 parents d66a4e7 + f4a9b99 commit fd1f0b3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/actions/SetBlendMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ var PropertyValueSet = require('./PropertyValueSet');
* Takes an array of Game Objects, or any objects that have the public property `blendMode`
* and then sets it to the given value.
*
* The optional `step` property is applied incrementally, multiplied by each item in the array.
*
* To use this with a Group: `SetBlendMode(group.getChildren(), value)`
*
* @function Phaser.Actions.SetBlendMode
Expand All @@ -20,7 +18,7 @@ var PropertyValueSet = require('./PropertyValueSet');
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to.
* @param {(Phaser.BlendModes|string|number)} value - The Blend Mode to be set.
* @param {number} [index=0] - An optional offset to start searching from within the items array.
* @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
*
Expand Down
6 changes: 3 additions & 3 deletions src/actions/SetHitArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
* Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks.
*
*
* @see {@link Phaser.GameObjects.GameObject#setInteractive}
*
* @function Phaser.Actions.SetHitArea
Expand All @@ -15,8 +15,8 @@
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action.
* @param {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
* @param {Phaser.Types.Input.HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback.
* @param {(Phaser.Types.Input.InputConfiguration|any)} [hitArea] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not given it will try to create a Rectangle based on the texture frame.
* @param {Phaser.Types.Input.HitAreaCallback} [callback] - The callback that determines if the pointer is within the Hit Area shape or not. If you provide a shape you must also provide a callback.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
Expand Down
26 changes: 23 additions & 3 deletions src/physics/arcade/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,9 @@ var Body = new Class({
* @since 3.0.0
*/
this._bounds = new Rectangle();

this.autoUpdate = false;

},

/**
Expand Down Expand Up @@ -1110,7 +1113,7 @@ var Body = new Class({
this.rotation = this.transform.rotation;
this.preRotation = this.rotation;

if (this.moves)
if (this.moves && !this.autoUpdate)
{
var pos = this.position;

Expand Down Expand Up @@ -1144,16 +1147,27 @@ var Body = new Class({
this.prev.x = this.position.x;
this.prev.y = this.position.y;

if (this.autoUpdate)
{
this.velocity.set(
(this.position.x - this.prevFrame.x) / delta,
(this.position.y - this.prevFrame.y) / delta
);
}

if (this.moves)
{
this.world.updateMotion(this, delta);

var vx = this.velocity.x;
var vy = this.velocity.y;

this.newVelocity.set(vx * delta, vy * delta);
if (!this.autoUpdate)
{
this.newVelocity.set(vx * delta, vy * delta);

this.position.add(this.newVelocity);
this.position.add(this.newVelocity);
}

this.updateCenter();

Expand Down Expand Up @@ -1248,6 +1262,12 @@ var Body = new Class({

this._tx = dx;
this._ty = dy;

if (this.autoUpdate)
{
this.prevFrame.x = this.position.x;
this.prevFrame.y = this.position.y;
}
},

/**
Expand Down

0 comments on commit fd1f0b3

Please sign in to comment.