Skip to content

Commit

Permalink
v3.61 Beta 4
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Oct 27, 2023
1 parent 2bf377b commit ef1ef79
Show file tree
Hide file tree
Showing 10 changed files with 1,000,318 additions and 151 deletions.
189 changes: 155 additions & 34 deletions dist/phaser-arcade-physics.js
Expand Up @@ -367,9 +367,14 @@ if (true) {
var QuickSet = __webpack_require__(82590);

/**
* Takes an array of Game Objects, or any objects that have public `x` and `y` properties, and aligns them next to each other.
* Takes an array of Game Objects and aligns them next to each other.
*
* The first item isn't moved. The second item is aligned next to the first, then the third next to the second, and so on.
* The alignment position is controlled by the `position` parameter, which should be one
* of the Phaser.Display.Align constants, such as `Phaser.Display.Align.TOP_LEFT`,
* `Phaser.Display.Align.TOP_CENTER`, etc.
*
* The first item isn't moved. The second item is aligned next to the first,
* then the third next to the second, and so on.
*
* @function Phaser.Actions.AlignTo
* @since 3.22.0
Expand Down Expand Up @@ -1883,8 +1888,6 @@ var PropertyValueSet = __webpack_require__(23646);
* 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 @@ -1893,7 +1896,7 @@ var PropertyValueSet = __webpack_require__(23646);
* @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 Expand Up @@ -1962,7 +1965,7 @@ module.exports = SetDepth;

/**
* 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 @@ -1971,8 +1974,8 @@ module.exports = SetDepth;
* @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 Expand Up @@ -2735,8 +2738,17 @@ var MathSmoothStep = __webpack_require__(5514);

/**
* Smoothstep is a sigmoid-like interpolation and clamping function.
*
* The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques.
*
* The function depends on three parameters, the input x, the "left edge"
* and the "right edge", with the left edge being assumed smaller than the right edge.
*
* The function receives a real number x as an argument and returns 0 if x is less than
* or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly
* interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the
* smoothstep function is zero at both edges.
*
* This is convenient for creating a sequence of transitions using smoothstep to interpolate
* each segment as an alternative to using more sophisticated or expensive interpolation techniques.
*
* @function Phaser.Actions.SmoothStep
* @since 3.0.0
Expand All @@ -2747,7 +2759,7 @@ var MathSmoothStep = __webpack_require__(5514);
* @param {string} property - The property of the Game Object to interpolate.
* @param {number} min - The minimum interpolation value.
* @param {number} max - The maximum interpolation value.
* @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`)
* @param {boolean} [inc=false] - Should the property value be incremented (`true`) or set (`false`)?
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
Expand Down Expand Up @@ -15706,7 +15718,7 @@ var CONST = {
* @type {string}
* @since 3.0.0
*/
VERSION: '3.61.0-beta.3',
VERSION: '3.61.0-beta.4',

BlendModes: __webpack_require__(95723),

Expand Down Expand Up @@ -141247,6 +141259,30 @@ var Body = new Class({
* @since 3.0.0
*/
this._bounds = new Rectangle();

/**
* Is this Body under direct control, outside of the physics engine? For example,
* are you trying to move it via a Tween? Or have it follow a path? If so then
* you can enable this boolean so that the Body will calculate its velocity based
* purely on its change in position each frame. This allows you to then tween
* the position and still have it collide with other objects. However, setting
* the velocity will have no impact on this Body while this is set.
*
* @name Phaser.Physics.Arcade.Body#directControl
* @type {boolean}
* @since 3.61.0
*/
this.directControl = false;

/**
* Stores the previous position of the Game Object when directControl is enabled.
*
* @name Phaser.Physics.Arcade.Body#autoFrame
* @type {Phaser.Math.Vector2}
* @private
* @since 3.61.0
*/
this.autoFrame = this.position.clone();
},

/**
Expand Down Expand Up @@ -141432,6 +141468,7 @@ var Body = new Class({

this.prev.x = pos.x;
this.prev.y = pos.y;

this.prevFrame.x = pos.x;
this.prevFrame.y = pos.y;
}
Expand All @@ -141457,36 +141494,63 @@ var Body = new Class({
*/
update: function (delta)
{
this.prev.x = this.position.x;
this.prev.y = this.position.y;
var prev = this.prev;
var pos = this.position;
var vel = this.velocity;

if (this.moves)
prev.set(pos.x, pos.y);

if (!this.moves)
{
this.world.updateMotion(this, delta);
this._dx = pos.x - prev.x;
this._dy = pos.y - prev.y;

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

this.newVelocity.set(vx * delta, vy * delta);
if (this.directControl)
{
var autoFrame = this.autoFrame;

this.position.add(this.newVelocity);
vel.set(
(pos.x - autoFrame.x) / delta,
(pos.y - autoFrame.y) / delta
);

this.updateCenter();
this.world.updateMotion(this, delta);

this.angle = Math.atan2(vy, vx);
this.speed = Math.sqrt(vx * vx + vy * vy);
this._dx = pos.x - autoFrame.x;
this._dy = pos.y - autoFrame.y;
}
else
{
this.world.updateMotion(this, delta);

// Now the update will throw collision checks at the Body
// And finally we'll integrate the new position back to the Sprite in postUpdate
this.newVelocity.set(vel.x * delta, vel.y * delta);

if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds)
{
this.world.emit(Events.WORLD_BOUNDS, this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right);
}
pos.add(this.newVelocity);

this._dx = pos.x - prev.x;
this._dy = pos.y - prev.y;
}

this._dx = this.position.x - this.prev.x;
this._dy = this.position.y - this.prev.y;
var vx = vel.x;
var vy = vel.y;

this.updateCenter();

this.angle = Math.atan2(vy, vx);
this.speed = Math.sqrt(vx * vx + vy * vy);

// Now the update will throw collision checks at the Body
// And finally we'll integrate the new position back to the Sprite in postUpdate

if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds)
{
var blocked = this.blocked;

this.world.emit(Events.WORLD_BOUNDS, this, blocked.up, blocked.down, blocked.left, blocked.right);
}
},

/**
Expand All @@ -141499,8 +141563,11 @@ var Body = new Class({
*/
postUpdate: function ()
{
var dx = this.position.x - this.prevFrame.x;
var dy = this.position.y - this.prevFrame.y;
var pos = this.position;

var dx = pos.x - this.prevFrame.x;
var dy = pos.y - this.prevFrame.y;

var gameObject = this.gameObject;

if (this.moves)
Expand Down Expand Up @@ -141564,6 +141631,8 @@ var Body = new Class({

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

this.autoFrame.set(pos.x, pos.y);
},

/**
Expand Down Expand Up @@ -141850,6 +141919,7 @@ var Body = new Class({

this.prev.copy(pos);
this.prevFrame.copy(pos);
this.autoFrame.copy(pos);

if (gameObject)
{
Expand Down Expand Up @@ -142176,6 +142246,30 @@ var Body = new Class({
return (this.debugShowBody || this.debugShowVelocity);
},

/**
* Sets whether this Body should calculate its velocity based on its change in
* position every frame. The default, which is to not do this, means that you
* make this Body move by setting the velocity directly. However, if you are
* trying to move this Body via a Tween, or have it follow a Path, then you
* should enable this instead. This will allow it to still collide with other
* bodies, something that isn't possible if you're just changing its position directly.
*
* @method Phaser.Physics.Arcade.Body#setDirectControl
* @since 3.61.0
*
* @param {boolean} [value=true] - `true` if the Body calculate velocity based on changes in position, otherwise `false`.
*
* @return {Phaser.Physics.Arcade.Body} This Body object.
*/
setDirectControl: function (value)
{
if (value === undefined) { value = true; }

this.directControl = value;

return this;
},

/**
* Sets whether this Body collides with the world boundary.
*
Expand Down Expand Up @@ -149752,6 +149846,28 @@ module.exports = Drag;
*/
var Enable = {

/**
* Sets whether this Body should calculate its velocity based on its change in
* position every frame. The default, which is to not do this, means that you
* make this Body move by setting the velocity directly. However, if you are
* trying to move this Body via a Tween, or have it follow a Path, then you
* should enable this instead. This will allow it to still collide with other
* bodies, something that isn't possible if you're just changing its position directly.
*
* @method Phaser.Physics.Arcade.Components.Enable#setDirectControl
* @since 3.61.0
*
* @param {boolean} [value=true] - `true` if the Body calculate velocity based on changes in position, otherwise `false`.
*
* @return {this} This Game Object.
*/
setDirectControl: function (value)
{
this.body.setDirectControl(value);

return this;
},

/**
* Enables this Game Object's Body.
* If you reset the Body you must also pass `x` and `y`.
Expand Down Expand Up @@ -190872,7 +190988,12 @@ var DynamicTexture = new Class({

if (!isCanvas)
{
this.setFromRenderTarget();
var frame = this.get();
var textureSource = frame.source;

textureSource.isRenderTexture = true;
textureSource.isGLTexture = true;
textureSource.glTexture.flipY = true;
}
},

Expand Down
2 changes: 1 addition & 1 deletion dist/phaser-arcade-physics.min.js

Large diffs are not rendered by default.

0 comments on commit ef1ef79

Please sign in to comment.