Skip to content

Commit 1225294

Browse files
committed
Time.add allows you to add an existing Phaser.Timer to the timer pool (request phaserjs#864)
1 parent 1d428a7 commit 1225294

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Version 2.0.6 - "Jornhill" - -in development-
6262
* Loader.physics has renamed the `dataURL` parameter to `url` and `jsonData` to `data` to keep it consistent with the other Loader methods.
6363
* Stage no longer creates the Phaser.Canvas object, but Game itself does in the setupRenderer method.
6464
* Canvas.create has deprecated the noCocoon parameter as it's no longer required. The parameter is still in the signature, but no longer used in the method.
65+
* Time.add allows you to add an existing Phaser.Timer to the timer pool (request #864)
6566

6667
### CocoonJS Specific Updates
6768

@@ -99,6 +100,7 @@ Version 2.0.6 - "Jornhill" - -in development-
99100
* Timer.ms would report the game time ms value if the Timer hadn't yet been started, instead of 0.
100101
* Timer.seconds would report the game time value if the Timer hadn't yet been started, instead of 0.
101102
* A Canvas style set from a game config object used an incorrect property (thanks @TatumCreative, fix #861)
103+
* Phaser.Line.intersectsPoints fixed for floating point inaccuracy (thanks @woutercommandeur, fix #865)
102104

103105
### Migration Guide
104106

build/phaser.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4824,6 +4824,7 @@ declare module Phaser {
48244824
time: number;
48254825
timeToCall: number;
48264826

4827+
add(timer: Phaser.Timer): Phaser.Timer;
48274828
boot(): void;
48284829
create(autoDestroy?: boolean): Phaser.Timer;
48294830
elapsedSecondsSince(since: number): number;

src/time/Time.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,21 @@ Phaser.Time.prototype = {
175175

176176
},
177177

178+
/**
179+
* Adds an existing Phaser.Timer object to the Timer pool.
180+
*
181+
* @method Phaser.Time#add
182+
* @param {Phaser.Timer} timer - An existing Phaser.Timer object.
183+
* @return {Phaser.Timer} The given Phaser.Timer object.
184+
*/
185+
add: function (timer) {
186+
187+
this._timers.push(timer);
188+
189+
return timer;
190+
191+
},
192+
178193
/**
179194
* Creates a new stand-alone Phaser.Timer object.
180195
*

0 commit comments

Comments
 (0)