Skip to content

Commit c3c1165

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser into types/group-classType
2 parents 8e717d5 + a39c0c8 commit c3c1165

12 files changed

Lines changed: 677 additions & 1351 deletions

File tree

.github/FUNDING.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# These are supported funding model platforms
2+
3+
github: photonstorm
4+
patreon: photonstorm
5+
custom: https://phaser.io/community/donate

CHANGELOG.md

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

33
## Version 3.18.0 - Raphtalia - in dev
44

5+
### Input System Changes
6+
7+
The old 'input queue' legacy system, which was deprecated in 3.16, has been removed entirely in order to tidy-up the API and keep input events consistent. This means the following changes:
8+
9+
* Removed the `inputQueue` Game config property.
10+
* Removed the `useQueue`, `queue` and `_updatedThisFrame` properties from the Input Manager.
11+
* Removed the `legacyUpdate` and `update` methods from the Input Manager.
12+
* Removed the `ignoreEvents` property as this should now be handled on a per-event basis.
13+
* The Input Manager no longer listens for the `GameEvents.POST_STEP` event.
14+
15+
As a result, all of the following Input Manager methods have been renamed:
16+
17+
* `queueTouchStart` is now called `onTouchStart` and invoked by the Touch Manager.
18+
* `queueTouchMove` is now called `onTouchMove` and invoked by the Touch Manager.
19+
* `queueTouchEnd` is now called `onTouchEnd` and invoked by the Touch Manager.
20+
* `queueTouchCancel` is now called `onTouchCancel` and invoked by the Touch Manager.
21+
* `queueMouseDown` is now called `onMouseDown` and invoked by the Mouse Manager.
22+
* `queueMouseMove` is now called `onMouseMove` and invoked by the Mouse Manager.
23+
* `queueMouseUp` is now called `onMouseUp` and invoked by the Mouse Manager.
24+
25+
Each of these handlers used to check the `enabled` state of the Input Manager, but this now handled directly in the Touch and Mouse Managers instead, leading to less branching and cleaner tests.
26+
27+
Because the legacy queue mode is gone, there is no longer any need for the DOM Callbacks:
28+
29+
* Removed the `_hasUpCallback`, `_hasDownCallback` and `_hasMoveCallback` properties from the Input Manager
30+
* Removed the `processDomCallbacks`, `addDownCallback`, `addUpCallback`, `addMoveCallback`, `domCallbacks`, `addDownCallback`, `addUpCallback` and `addMoveCallback` methods.
31+
32+
Also, CSS cursors can now be set directly:
33+
34+
* Cursors are now set and reset immediately on the canvas, leading to the removal of `_setCursor` and `_customCursor` properties.
35+
36+
The following changes took place in the Input Plugin class:
37+
38+
* The method `processDragEvents` has been removed as it's now split across smaller, more explicit methods.
39+
* `processDragDownEvent` is a new method that handles a down event for drag enabled Game Objects.
40+
* `processDragMoveEvent` is a new method that handles a move event for drag enabled Game Objects.
41+
* `processDragUpEvent` is a new method that handles an up event for drag enabled Game Objects.
42+
* `processDragStartList` is a new internal method that builds a drag list for a pointer.
43+
* `processDragThresholdEvent` is a new internal method that tests when a pointer with drag thresholds can drag.
44+
45+
The following changes took place in the Pointer class:
46+
47+
* `Pointer.dirty` has been removed as it's no longer required.
48+
* `Pointer.justDown` has been removed as it's not used internally and makes no sense under the DOM event system.
49+
* `Pointer.justUp` has been removed as it's not used internally and makes no sense under the DOM event system.
50+
* `Pointer.justMoved` has been removed as it's not used internally and makes no sense under the DOM event system.
51+
* The `Pointer.reset` method has been removed as it's no longer required internally.
52+
53+
#### Input System Bug Fixes
54+
55+
* Calling `setPollAlways()` would cause the `'pointerdown'` event to fire multiple times. Fix #4541 (thanks @Neyromantik)
56+
* The pointer events were intermittently not registered, causing `pointerup` to often fail. Fix #4538 (thanks @paulsymphony)
57+
* Due to a regression in 3.16 the drag events were not performing as fast as before, causing drags to feel lagged. Fix #4500 (thanks @aliblong)
58+
559
### New Features
660

761
* `Matter.Factory.velocity` is a new method that allows you to set the velocity on a Matter Body directly.
@@ -14,13 +68,24 @@
1468
* The default `BaseShader` vertex shader has a new uniform `uResolution` which is set during the Shader init and load to be the size of the Game Object to which the shader is bound.
1569
* The default `BaseShader` vertex shader will now set the `fragCoord` varying to be the Game Object height minus the y inPosition. This will give the correct y axis in the fragment shader, causing 'inverted' shaders to display normally when using the default vertex code.
1670
* There was some test code left in the `DOMElementCSSRenderer` file that caused `getBoundingClientRect` to be called every render. This has been removed, which increases performance significantly for DOM heavy games.
71+
* The `TimeStep` will no longer set its `frame` property to zero in the `resetDelta` method. Instead, this property is incremented every step, no matter what, giving an accurate indication of exactly which frame something happened on internally.
72+
* The `TimeStep.step` method no longer uses the time value passed to the raf callback, as it's not actually the current point in time, but rather the time that the main thread began at. Which doesn't help if we're comparing it to event timestamps.
73+
* `TimeStep.now` is a new property that holds the exact `performance.now` value, as set at the start of the current game step.
1774

1875
### Bug Fixes
1976

2077
* Tweens created in a paused state couldn't be started by a call to `play`. Fix #4525 (thanks @TonioParis)
2178
* If both Arcade Physics circle body positions and the delta equaled zero, the `separateCircle` function would cause the position to be set `NaN` (thanks @hizzd)
2279
* The `CameraManager` would incorrectly destroy the `default` Camera in its shutdown method, meaning that if you used a fixed mask camera and stopped then resumed a Scene, the masks would stop working. The default camera is now destroyed only in the `destroy` method. Fix #4520 (thanks @telinc1)
2380
* Passing a Frame object to `Bob.setFrame` would fail, as it expected a string or integer. It now checks the type of object, and if a Frame it checks to make sure it's a Frame belonging to the parent Blitter's texture, and if so sets it. Fix #4516 (thanks @NokFrt)
81+
* The ScaleManager full screen call had an arrow function in it. Despite being within a conditional block of code it still broke really old browsers like IE11, so has been removed. Fix #4530 (thanks @jorbascrumps @CNDW)
82+
* `Game.getTime` would return `NaN` because it incorrectly accessed the time value from the TimeStep.
83+
84+
### Examples, Documentation and TypeScript
85+
86+
My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs:
87+
88+
@PhaserEditor2D @samme
2489

2590

2691

src/core/Config.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,6 @@ var Config = new Class({
270270
*/
271271
this.inputSmoothFactor = GetValue(config, 'input.smoothFactor', 0);
272272

273-
/**
274-
* @const {boolean} Phaser.Core.Config#inputQueue - Should Phaser use a queued input system for native DOM Events or not?
275-
*/
276-
this.inputQueue = GetValue(config, 'input.queue', false);
277-
278273
/**
279274
* @const {boolean} Phaser.Core.Config#inputWindowEvents - Should Phaser listen for input events on the Window? If you disable this, events like 'POINTER_UP_OUTSIDE' will no longer fire.
280275
*/

src/core/Game.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ var Game = new Class({
604604

605605
/**
606606
* Returns the current game frame.
607+
*
607608
* When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires.
608609
*
609610
* @method Phaser.Game#getFrame
@@ -617,8 +618,7 @@ var Game = new Class({
617618
},
618619

619620
/**
620-
* Returns the current game timestamp.
621-
* When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires.
621+
* Returns the time that the current game step started at, as based on `performance.now`.
622622
*
623623
* @method Phaser.Game#getTime
624624
* @since 3.16.0
@@ -627,7 +627,7 @@ var Game = new Class({
627627
*/
628628
getTime: function ()
629629
{
630-
return this.loop.frame.time;
630+
return this.loop.now;
631631
},
632632

633633
/**

src/core/TimeStep.js

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -185,37 +185,39 @@ var TimeStep = new Class({
185185
this.forceSetTimeOut = GetValue(config, 'forceSetTimeOut', false);
186186

187187
/**
188-
* [description]
188+
* The time, calculated at the start of the current step, as smoothed by the delta value.
189189
*
190190
* @name Phaser.Core.TimeStep#time
191-
* @type {integer}
191+
* @type {number}
192192
* @default 0
193193
* @since 3.0.0
194194
*/
195195
this.time = 0;
196196

197197
/**
198-
* [description]
198+
* The time at which the game started running. This value is adjusted if the game is then
199+
* paused and resumes.
199200
*
200201
* @name Phaser.Core.TimeStep#startTime
201-
* @type {integer}
202+
* @type {number}
202203
* @default 0
203204
* @since 3.0.0
204205
*/
205206
this.startTime = 0;
206207

207208
/**
208-
* [description]
209+
* The time, as returned by `performance.now` of the previous step.
209210
*
210211
* @name Phaser.Core.TimeStep#lastTime
211-
* @type {integer}
212+
* @type {number}
212213
* @default 0
213214
* @since 3.0.0
214215
*/
215216
this.lastTime = 0;
216217

217218
/**
218-
* [description]
219+
* The current frame the game is on. This counter is incremented once every game step, regardless of how much
220+
* time has passed and is unaffected by delta smoothing.
219221
*
220222
* @name Phaser.Core.TimeStep#frame
221223
* @type {integer}
@@ -226,7 +228,8 @@ var TimeStep = new Class({
226228
this.frame = 0;
227229

228230
/**
229-
* [description]
231+
* Is the browser currently considered in focus by the Page Visibility API?
232+
* This value is set in the `blur` method, which is called automatically by the Game instance.
230233
*
231234
* @name Phaser.Core.TimeStep#inFocus
232235
* @type {boolean}
@@ -237,18 +240,18 @@ var TimeStep = new Class({
237240
this.inFocus = true;
238241

239242
/**
240-
* [description]
243+
* The timestamp at which the game became paused, as determined by the Page Visibility API.
241244
*
242245
* @name Phaser.Core.TimeStep#_pauseTime
243-
* @type {integer}
246+
* @type {number}
244247
* @private
245248
* @default 0
246249
* @since 3.0.0
247250
*/
248251
this._pauseTime = 0;
249252

250253
/**
251-
* [description]
254+
* An internal counter to allow for the browser 'cooling down' after coming back into focus.
252255
*
253256
* @name Phaser.Core.TimeStep#_coolDown
254257
* @type {integer}
@@ -259,7 +262,7 @@ var TimeStep = new Class({
259262
this._coolDown = 0;
260263

261264
/**
262-
* [description]
265+
* The delta time, in ms, since the last game step. This is a clamped and smoothed average value.
263266
*
264267
* @name Phaser.Core.TimeStep#delta
265268
* @type {integer}
@@ -269,7 +272,7 @@ var TimeStep = new Class({
269272
this.delta = 0;
270273

271274
/**
272-
* [description]
275+
* Internal index of the delta history position.
273276
*
274277
* @name Phaser.Core.TimeStep#deltaIndex
275278
* @type {integer}
@@ -279,7 +282,7 @@ var TimeStep = new Class({
279282
this.deltaIndex = 0;
280283

281284
/**
282-
* [description]
285+
* Internal array holding the previous delta values, used for delta smoothing.
283286
*
284287
* @name Phaser.Core.TimeStep#deltaHistory
285288
* @type {integer[]}
@@ -288,7 +291,9 @@ var TimeStep = new Class({
288291
this.deltaHistory = [];
289292

290293
/**
291-
* [description]
294+
* The maximum number of delta values that are retained in order to calculate a smoothed moving average.
295+
*
296+
* This can be changed in the Game Config via the `fps.deltaHistory` property. The default is 10.
292297
*
293298
* @name Phaser.Core.TimeStep#deltaSmoothingMax
294299
* @type {integer}
@@ -298,7 +303,10 @@ var TimeStep = new Class({
298303
this.deltaSmoothingMax = GetValue(config, 'deltaHistory', 10);
299304

300305
/**
301-
* [description]
306+
* The number of frames that the cooldown is set to after the browser panics over the FPS rate, usually
307+
* as a result of switching tabs and regaining focus.
308+
*
309+
* This can be changed in the Game Config via the `fps.panicMax` property. The default is 120.
302310
*
303311
* @name Phaser.Core.TimeStep#panicMax
304312
* @type {integer}
@@ -309,19 +317,31 @@ var TimeStep = new Class({
309317

310318
/**
311319
* The actual elapsed time in ms between one update and the next.
312-
* Unlike with `delta` no smoothing, capping, or averaging is applied to this value.
313-
* So please be careful when using this value in calculations.
320+
*
321+
* Unlike with `delta`, no smoothing, capping, or averaging is applied to this value.
322+
* So please be careful when using this value in math calculations.
314323
*
315324
* @name Phaser.Core.TimeStep#rawDelta
316325
* @type {number}
317326
* @default 0
318327
* @since 3.0.0
319328
*/
320329
this.rawDelta = 0;
330+
331+
/**
332+
* The time, as returned by `performance.now` at the very start of the current step.
333+
* This can differ from the `time` value in that it isn't calculated based on the delta value.
334+
*
335+
* @name Phaser.Core.TimeStep#now
336+
* @type {number}
337+
* @default 0
338+
* @since 3.18.0
339+
*/
340+
this.now = 0;
321341
},
322342

323343
/**
324-
* Called when the DOM window.onBlur event triggers.
344+
* Called by the Game instance when the DOM window.onBlur event triggers.
325345
*
326346
* @method Phaser.Core.TimeStep#blur
327347
* @since 3.0.0
@@ -332,7 +352,7 @@ var TimeStep = new Class({
332352
},
333353

334354
/**
335-
* Called when the DOM window.onFocus event triggers.
355+
* Called by the Game instance when the DOM window.onFocus event triggers.
336356
*
337357
* @method Phaser.Core.TimeStep#focus
338358
* @since 3.0.0
@@ -369,7 +389,8 @@ var TimeStep = new Class({
369389
},
370390

371391
/**
372-
* [description]
392+
* Resets the time, lastTime, fps averages and delta history.
393+
* Called automatically when a browser sleeps them resumes.
373394
*
374395
* @method Phaser.Core.TimeStep#resetDelta
375396
* @since 3.0.0
@@ -382,7 +403,6 @@ var TimeStep = new Class({
382403
this.lastTime = now;
383404
this.nextFpsUpdate = now + 1000;
384405
this.framesThisSecond = 0;
385-
this.frame = 0;
386406

387407
// Pre-populate smoothing array
388408

@@ -437,11 +457,17 @@ var TimeStep = new Class({
437457
*
438458
* @method Phaser.Core.TimeStep#step
439459
* @since 3.0.0
440-
*
441-
* @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
442460
*/
443-
step: function (time)
461+
step: function ()
444462
{
463+
// Because the timestamp passed in from raf represents the beginning of the main thread frame that we’re currently in,
464+
// not the actual time now. As we want to compare this time value against Event timeStamps and the like, we need a
465+
// more accurate one:
466+
467+
var time = window.performance.now();
468+
469+
this.now = time;
470+
445471
var before = time - this.lastTime;
446472

447473
if (before < 0)
@@ -556,14 +582,14 @@ var TimeStep = new Class({
556582
},
557583

558584
/**
559-
* Manually calls TimeStep.step, passing in the performance.now value to it.
585+
* Manually calls `TimeStep.step`.
560586
*
561587
* @method Phaser.Core.TimeStep#tick
562588
* @since 3.0.0
563589
*/
564590
tick: function ()
565591
{
566-
this.step(window.performance.now());
592+
this.step();
567593
},
568594

569595
/**
@@ -606,7 +632,7 @@ var TimeStep = new Class({
606632

607633
this.running = true;
608634

609-
this.step(window.performance.now());
635+
this.step();
610636
},
611637

612638
/**

src/core/typedefs/InputConfig.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
* @property {(boolean|Phaser.Types.Core.GamepadInputConfig)} [gamepad=false] - Gamepad input configuration. `true` enables gamepad input.
99
* @property {integer} [activePointers=1] - The maximum number of touch pointers. See {@link Phaser.Input.InputManager#pointers}.
1010
* @property {number} [smoothFactor=0] - The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}.
11-
* @property {boolean} [inputQueue=false] - Should Phaser use a queued input system for native DOM Events or not?
1211
* @property {boolean} [windowEvents=true] - Should Phaser listen for input events on the Window? If you disable this, events like 'POINTER_UP_OUTSIDE' will no longer fire.
1312
*/

src/gameobjects/group/typedefs/GroupCreateConfig.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@
33
*
44
* key.length * frame.length * frameQuantity * (yoyo ? 2 : 1) * (1 + repeat)
55
*
6-
* In the simplest case, 1 + `repeat` objects will be created.
7-
*
8-
* If `max` is positive, then the total created will not exceed `max`.
6+
* If `max` is nonzero, then the total created will not exceed `max`.
97
*
108
* `key` is required. {@link Phaser.GameObjects.Group#defaultKey} is not used.
11-
*
9+
*
1210
* @typedef {object} Phaser.Types.GameObjects.Group.GroupCreateConfig
1311
* @since 3.0.0
1412
*
1513
* @property {?Function} [classType] - The class of each new Game Object.
16-
* @property {string} [key] - The texture key of each new Game Object.
17-
* @property {?(string|integer)} [frame=null] - The texture frame of each new Game Object.
14+
* @property {(string|string[])} [key] - The texture key of each new Game Object.
15+
* @property {?(string|string[]|integer|integer[])} [frame=null] - The texture frame of each new Game Object.
1816
* @property {?boolean} [visible=true] - The visible state of each new Game Object.
1917
* @property {?boolean} [active=true] - The active state of each new Game Object.
2018
* @property {?number} [repeat=0] - The number of times each `key` × `frame` combination will be *repeated* (after the first combination).

0 commit comments

Comments
 (0)