Skip to content

Commit ef1ef79

Browse files
committed
v3.61 Beta 4
1 parent 2bf377b commit ef1ef79

File tree

10 files changed

+1000318
-151
lines changed

10 files changed

+1000318
-151
lines changed

dist/phaser-arcade-physics.js

Lines changed: 155 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,14 @@ if (true) {
367367
var QuickSet = __webpack_require__(82590);
368368

369369
/**
370-
* Takes an array of Game Objects, or any objects that have public `x` and `y` properties, and aligns them next to each other.
370+
* Takes an array of Game Objects and aligns them next to each other.
371371
*
372-
* 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.
372+
* The alignment position is controlled by the `position` parameter, which should be one
373+
* of the Phaser.Display.Align constants, such as `Phaser.Display.Align.TOP_LEFT`,
374+
* `Phaser.Display.Align.TOP_CENTER`, etc.
375+
*
376+
* The first item isn't moved. The second item is aligned next to the first,
377+
* then the third next to the second, and so on.
373378
*
374379
* @function Phaser.Actions.AlignTo
375380
* @since 3.22.0
@@ -1883,8 +1888,6 @@ var PropertyValueSet = __webpack_require__(23646);
18831888
* Takes an array of Game Objects, or any objects that have the public property `blendMode`
18841889
* and then sets it to the given value.
18851890
*
1886-
* The optional `step` property is applied incrementally, multiplied by each item in the array.
1887-
*
18881891
* To use this with a Group: `SetBlendMode(group.getChildren(), value)`
18891892
*
18901893
* @function Phaser.Actions.SetBlendMode
@@ -1893,7 +1896,7 @@ var PropertyValueSet = __webpack_require__(23646);
18931896
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
18941897
*
18951898
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
1896-
* @param {number} value - The amount to set the property to.
1899+
* @param {(Phaser.BlendModes|string|number)} value - The Blend Mode to be set.
18971900
* @param {number} [index=0] - An optional offset to start searching from within the items array.
18981901
* @param {number} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
18991902
*
@@ -1962,7 +1965,7 @@ module.exports = SetDepth;
19621965

19631966
/**
19641967
* Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks.
1965-
*
1968+
*
19661969
* @see {@link Phaser.GameObjects.GameObject#setInteractive}
19671970
*
19681971
* @function Phaser.Actions.SetHitArea
@@ -1971,8 +1974,8 @@ module.exports = SetDepth;
19711974
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
19721975
*
19731976
* @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action.
1974-
* @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.
1975-
* @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.
1977+
* @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.
1978+
* @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.
19761979
*
19771980
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
19781981
*/
@@ -2735,8 +2738,17 @@ var MathSmoothStep = __webpack_require__(5514);
27352738

27362739
/**
27372740
* Smoothstep is a sigmoid-like interpolation and clamping function.
2738-
*
2739-
* 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.
2741+
*
2742+
* The function depends on three parameters, the input x, the "left edge"
2743+
* and the "right edge", with the left edge being assumed smaller than the right edge.
2744+
*
2745+
* The function receives a real number x as an argument and returns 0 if x is less than
2746+
* or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly
2747+
* interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the
2748+
* smoothstep function is zero at both edges.
2749+
*
2750+
* This is convenient for creating a sequence of transitions using smoothstep to interpolate
2751+
* each segment as an alternative to using more sophisticated or expensive interpolation techniques.
27402752
*
27412753
* @function Phaser.Actions.SmoothStep
27422754
* @since 3.0.0
@@ -2747,7 +2759,7 @@ var MathSmoothStep = __webpack_require__(5514);
27472759
* @param {string} property - The property of the Game Object to interpolate.
27482760
* @param {number} min - The minimum interpolation value.
27492761
* @param {number} max - The maximum interpolation value.
2750-
* @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`)
2762+
* @param {boolean} [inc=false] - Should the property value be incremented (`true`) or set (`false`)?
27512763
*
27522764
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
27532765
*/
@@ -15706,7 +15718,7 @@ var CONST = {
1570615718
* @type {string}
1570715719
* @since 3.0.0
1570815720
*/
15709-
VERSION: '3.61.0-beta.3',
15721+
VERSION: '3.61.0-beta.4',
1571015722

1571115723
BlendModes: __webpack_require__(95723),
1571215724

@@ -141247,6 +141259,30 @@ var Body = new Class({
141247141259
* @since 3.0.0
141248141260
*/
141249141261
this._bounds = new Rectangle();
141262+
141263+
/**
141264+
* Is this Body under direct control, outside of the physics engine? For example,
141265+
* are you trying to move it via a Tween? Or have it follow a path? If so then
141266+
* you can enable this boolean so that the Body will calculate its velocity based
141267+
* purely on its change in position each frame. This allows you to then tween
141268+
* the position and still have it collide with other objects. However, setting
141269+
* the velocity will have no impact on this Body while this is set.
141270+
*
141271+
* @name Phaser.Physics.Arcade.Body#directControl
141272+
* @type {boolean}
141273+
* @since 3.61.0
141274+
*/
141275+
this.directControl = false;
141276+
141277+
/**
141278+
* Stores the previous position of the Game Object when directControl is enabled.
141279+
*
141280+
* @name Phaser.Physics.Arcade.Body#autoFrame
141281+
* @type {Phaser.Math.Vector2}
141282+
* @private
141283+
* @since 3.61.0
141284+
*/
141285+
this.autoFrame = this.position.clone();
141250141286
},
141251141287

141252141288
/**
@@ -141432,6 +141468,7 @@ var Body = new Class({
141432141468

141433141469
this.prev.x = pos.x;
141434141470
this.prev.y = pos.y;
141471+
141435141472
this.prevFrame.x = pos.x;
141436141473
this.prevFrame.y = pos.y;
141437141474
}
@@ -141457,36 +141494,63 @@ var Body = new Class({
141457141494
*/
141458141495
update: function (delta)
141459141496
{
141460-
this.prev.x = this.position.x;
141461-
this.prev.y = this.position.y;
141497+
var prev = this.prev;
141498+
var pos = this.position;
141499+
var vel = this.velocity;
141462141500

141463-
if (this.moves)
141501+
prev.set(pos.x, pos.y);
141502+
141503+
if (!this.moves)
141464141504
{
141465-
this.world.updateMotion(this, delta);
141505+
this._dx = pos.x - prev.x;
141506+
this._dy = pos.y - prev.y;
141466141507

141467-
var vx = this.velocity.x;
141468-
var vy = this.velocity.y;
141508+
return;
141509+
}
141469141510

141470-
this.newVelocity.set(vx * delta, vy * delta);
141511+
if (this.directControl)
141512+
{
141513+
var autoFrame = this.autoFrame;
141471141514

141472-
this.position.add(this.newVelocity);
141515+
vel.set(
141516+
(pos.x - autoFrame.x) / delta,
141517+
(pos.y - autoFrame.y) / delta
141518+
);
141473141519

141474-
this.updateCenter();
141520+
this.world.updateMotion(this, delta);
141475141521

141476-
this.angle = Math.atan2(vy, vx);
141477-
this.speed = Math.sqrt(vx * vx + vy * vy);
141522+
this._dx = pos.x - autoFrame.x;
141523+
this._dy = pos.y - autoFrame.y;
141524+
}
141525+
else
141526+
{
141527+
this.world.updateMotion(this, delta);
141478141528

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

141482-
if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds)
141483-
{
141484-
this.world.emit(Events.WORLD_BOUNDS, this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right);
141485-
}
141531+
pos.add(this.newVelocity);
141532+
141533+
this._dx = pos.x - prev.x;
141534+
this._dy = pos.y - prev.y;
141486141535
}
141487141536

141488-
this._dx = this.position.x - this.prev.x;
141489-
this._dy = this.position.y - this.prev.y;
141537+
var vx = vel.x;
141538+
var vy = vel.y;
141539+
141540+
this.updateCenter();
141541+
141542+
this.angle = Math.atan2(vy, vx);
141543+
this.speed = Math.sqrt(vx * vx + vy * vy);
141544+
141545+
// Now the update will throw collision checks at the Body
141546+
// And finally we'll integrate the new position back to the Sprite in postUpdate
141547+
141548+
if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds)
141549+
{
141550+
var blocked = this.blocked;
141551+
141552+
this.world.emit(Events.WORLD_BOUNDS, this, blocked.up, blocked.down, blocked.left, blocked.right);
141553+
}
141490141554
},
141491141555

141492141556
/**
@@ -141499,8 +141563,11 @@ var Body = new Class({
141499141563
*/
141500141564
postUpdate: function ()
141501141565
{
141502-
var dx = this.position.x - this.prevFrame.x;
141503-
var dy = this.position.y - this.prevFrame.y;
141566+
var pos = this.position;
141567+
141568+
var dx = pos.x - this.prevFrame.x;
141569+
var dy = pos.y - this.prevFrame.y;
141570+
141504141571
var gameObject = this.gameObject;
141505141572

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

141565141632
this._tx = dx;
141566141633
this._ty = dy;
141634+
141635+
this.autoFrame.set(pos.x, pos.y);
141567141636
},
141568141637

141569141638
/**
@@ -141850,6 +141919,7 @@ var Body = new Class({
141850141919

141851141920
this.prev.copy(pos);
141852141921
this.prevFrame.copy(pos);
141922+
this.autoFrame.copy(pos);
141853141923

141854141924
if (gameObject)
141855141925
{
@@ -142176,6 +142246,30 @@ var Body = new Class({
142176142246
return (this.debugShowBody || this.debugShowVelocity);
142177142247
},
142178142248

142249+
/**
142250+
* Sets whether this Body should calculate its velocity based on its change in
142251+
* position every frame. The default, which is to not do this, means that you
142252+
* make this Body move by setting the velocity directly. However, if you are
142253+
* trying to move this Body via a Tween, or have it follow a Path, then you
142254+
* should enable this instead. This will allow it to still collide with other
142255+
* bodies, something that isn't possible if you're just changing its position directly.
142256+
*
142257+
* @method Phaser.Physics.Arcade.Body#setDirectControl
142258+
* @since 3.61.0
142259+
*
142260+
* @param {boolean} [value=true] - `true` if the Body calculate velocity based on changes in position, otherwise `false`.
142261+
*
142262+
* @return {Phaser.Physics.Arcade.Body} This Body object.
142263+
*/
142264+
setDirectControl: function (value)
142265+
{
142266+
if (value === undefined) { value = true; }
142267+
142268+
this.directControl = value;
142269+
142270+
return this;
142271+
},
142272+
142179142273
/**
142180142274
* Sets whether this Body collides with the world boundary.
142181142275
*
@@ -149752,6 +149846,28 @@ module.exports = Drag;
149752149846
*/
149753149847
var Enable = {
149754149848

149849+
/**
149850+
* Sets whether this Body should calculate its velocity based on its change in
149851+
* position every frame. The default, which is to not do this, means that you
149852+
* make this Body move by setting the velocity directly. However, if you are
149853+
* trying to move this Body via a Tween, or have it follow a Path, then you
149854+
* should enable this instead. This will allow it to still collide with other
149855+
* bodies, something that isn't possible if you're just changing its position directly.
149856+
*
149857+
* @method Phaser.Physics.Arcade.Components.Enable#setDirectControl
149858+
* @since 3.61.0
149859+
*
149860+
* @param {boolean} [value=true] - `true` if the Body calculate velocity based on changes in position, otherwise `false`.
149861+
*
149862+
* @return {this} This Game Object.
149863+
*/
149864+
setDirectControl: function (value)
149865+
{
149866+
this.body.setDirectControl(value);
149867+
149868+
return this;
149869+
},
149870+
149755149871
/**
149756149872
* Enables this Game Object's Body.
149757149873
* If you reset the Body you must also pass `x` and `y`.
@@ -190872,7 +190988,12 @@ var DynamicTexture = new Class({
190872190988

190873190989
if (!isCanvas)
190874190990
{
190875-
this.setFromRenderTarget();
190991+
var frame = this.get();
190992+
var textureSource = frame.source;
190993+
190994+
textureSource.isRenderTexture = true;
190995+
textureSource.isGLTexture = true;
190996+
textureSource.glTexture.flipY = true;
190876190997
}
190877190998
},
190878190999

dist/phaser-arcade-physics.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)