excalibur 0.32.0-alpha.1592 → 0.32.0-alpha.1593
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/build/dist/Timer.d.ts +27 -0
- package/build/dist/excalibur.development.js +28 -3
- package/build/dist/excalibur.js +28 -3
- package/build/dist/excalibur.min.development.js +4 -4
- package/build/dist/excalibur.min.js +4 -4
- package/build/esm/excalibur.development.js +28 -3
- package/build/esm/excalibur.js +28 -3
- package/build/esm/excalibur.min.development.js +172 -162
- package/build/esm/excalibur.min.js +172 -162
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,23 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
17
17
|
### Added
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
- Added new Timer events!
|
|
21
|
+
```typescript
|
|
22
|
+
const timer = new ex.Timer({...});
|
|
23
|
+
timer.events.on('complete', () => {...}); // after the last repeat
|
|
24
|
+
timer.events.on('action', () => {...}); // every fire of the timer
|
|
25
|
+
timer.events.on('start', () => {...}); // after the timer is started
|
|
26
|
+
timer.events.on('stop', () => {...}); // after the timer is stopped
|
|
27
|
+
timer.events.on('pause', () => {...}); // after every pause
|
|
28
|
+
timer.events.on('resume', () => {...}); // after every resume
|
|
29
|
+
timer.events.on('cancel', () => {...}); // after cancel
|
|
30
|
+
|
|
31
|
+
// or specify the onComplete in the constructor
|
|
32
|
+
const timer2 = new ex.Timer({
|
|
33
|
+
onComplete: () => {...},
|
|
34
|
+
...
|
|
35
|
+
});
|
|
36
|
+
```
|
|
20
37
|
- Added a way to configure general debug settings on text
|
|
21
38
|
```typescript
|
|
22
39
|
class DebugConfig {
|
package/build/dist/Timer.d.ts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import type { Scene } from './Scene';
|
|
2
2
|
import type * as ex from './index';
|
|
3
|
+
/**
|
|
4
|
+
* Built in events supported by all entities
|
|
5
|
+
*/
|
|
6
|
+
export interface TimerEvents {
|
|
7
|
+
start: void;
|
|
8
|
+
stop: void;
|
|
9
|
+
pause: void;
|
|
10
|
+
resume: void;
|
|
11
|
+
cancel: void;
|
|
12
|
+
action: void;
|
|
13
|
+
complete: void;
|
|
14
|
+
}
|
|
15
|
+
export declare const TimerEvents: {
|
|
16
|
+
readonly Start: "start";
|
|
17
|
+
readonly Stop: "stop";
|
|
18
|
+
readonly Pause: "pause";
|
|
19
|
+
readonly Resume: "resume";
|
|
20
|
+
readonly Cancel: "cancel";
|
|
21
|
+
readonly Action: "action";
|
|
22
|
+
readonly Complete: "complete";
|
|
23
|
+
};
|
|
3
24
|
export interface TimerOptions {
|
|
4
25
|
/**
|
|
5
26
|
* If true the timer repeats every interval infinitely
|
|
@@ -29,6 +50,10 @@ export interface TimerOptions {
|
|
|
29
50
|
* Optionally provide a random instance to use for random behavior, otherwise a new random will be created seeded from the current time.
|
|
30
51
|
*/
|
|
31
52
|
random?: ex.Random;
|
|
53
|
+
/**
|
|
54
|
+
* Optionally provide a callback to fire once when the timer completes its last action callback.
|
|
55
|
+
*/
|
|
56
|
+
onComplete?: () => void;
|
|
32
57
|
}
|
|
33
58
|
/**
|
|
34
59
|
* The Excalibur timer hooks into the internal timer and fires callbacks,
|
|
@@ -38,6 +63,7 @@ export declare class Timer {
|
|
|
38
63
|
private _logger;
|
|
39
64
|
private static _MAX_ID;
|
|
40
65
|
id: number;
|
|
66
|
+
events: ex.EventEmitter<ex.TimerEvents>;
|
|
41
67
|
private _elapsedTime;
|
|
42
68
|
private _totalTimeAlive;
|
|
43
69
|
private _running;
|
|
@@ -50,6 +76,7 @@ export declare class Timer {
|
|
|
50
76
|
random: ex.Random;
|
|
51
77
|
private _baseInterval;
|
|
52
78
|
private _generateRandomInterval;
|
|
79
|
+
private _onComplete;
|
|
53
80
|
private _complete;
|
|
54
81
|
get complete(): boolean;
|
|
55
82
|
scene: Scene;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1593+0f899e4 - 2025-12-6
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -24804,10 +24804,20 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24804
24804
|
return super.contains(coords.x, coords.y);
|
|
24805
24805
|
}
|
|
24806
24806
|
}
|
|
24807
|
+
const TimerEvents = {
|
|
24808
|
+
Start: "start",
|
|
24809
|
+
Stop: "stop",
|
|
24810
|
+
Pause: "pause",
|
|
24811
|
+
Resume: "resume",
|
|
24812
|
+
Cancel: "cancel",
|
|
24813
|
+
Action: "action",
|
|
24814
|
+
Complete: "complete"
|
|
24815
|
+
};
|
|
24807
24816
|
const _Timer = class _Timer2 {
|
|
24808
24817
|
constructor(options) {
|
|
24809
24818
|
this._logger = Logger.getInstance();
|
|
24810
24819
|
this.id = 0;
|
|
24820
|
+
this.events = new EventEmitter();
|
|
24811
24821
|
this._elapsedTime = 0;
|
|
24812
24822
|
this._totalTimeAlive = 0;
|
|
24813
24823
|
this._running = false;
|
|
@@ -24820,15 +24830,18 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24820
24830
|
this._generateRandomInterval = () => {
|
|
24821
24831
|
return this._baseInterval + this.random.integer(this.randomRange[0], this.randomRange[1]);
|
|
24822
24832
|
};
|
|
24833
|
+
this._onComplete = () => {
|
|
24834
|
+
};
|
|
24823
24835
|
this._complete = false;
|
|
24824
24836
|
this.scene = null;
|
|
24825
|
-
var _a;
|
|
24837
|
+
var _a, _b;
|
|
24826
24838
|
const fcn = (_a = options.action) != null ? _a : options.fcn;
|
|
24827
24839
|
const interval = options.interval;
|
|
24828
24840
|
const repeats = options.repeats;
|
|
24829
24841
|
const numberOfRepeats = options.numberOfRepeats;
|
|
24830
24842
|
const randomRange = options.randomRange;
|
|
24831
24843
|
const random = options.random;
|
|
24844
|
+
this._onComplete = (_b = options.onComplete) != null ? _b : this._onComplete;
|
|
24832
24845
|
if (!!numberOfRepeats && numberOfRepeats >= 0) {
|
|
24833
24846
|
this.maxNumberOfRepeats = numberOfRepeats;
|
|
24834
24847
|
if (!repeats) {
|
|
@@ -24884,18 +24897,23 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24884
24897
|
this._complete = true;
|
|
24885
24898
|
this._running = false;
|
|
24886
24899
|
this._elapsedTime = 0;
|
|
24900
|
+
this._onComplete();
|
|
24901
|
+
this.events.emit("complete");
|
|
24887
24902
|
}
|
|
24888
24903
|
if (!this.complete && this._elapsedTime >= this.interval) {
|
|
24889
24904
|
this._callbacks.forEach((c) => {
|
|
24890
24905
|
c.call(this);
|
|
24891
24906
|
});
|
|
24892
24907
|
this._numberOfTicks++;
|
|
24908
|
+
this.events.emit("action");
|
|
24893
24909
|
if (this.repeats) {
|
|
24894
24910
|
this._elapsedTime = 0;
|
|
24895
24911
|
} else {
|
|
24896
24912
|
this._complete = true;
|
|
24897
24913
|
this._running = false;
|
|
24898
24914
|
this._elapsedTime = 0;
|
|
24915
|
+
this._onComplete();
|
|
24916
|
+
this.events.emit("complete");
|
|
24899
24917
|
}
|
|
24900
24918
|
}
|
|
24901
24919
|
}
|
|
@@ -24950,6 +24968,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24950
24968
|
*/
|
|
24951
24969
|
pause() {
|
|
24952
24970
|
this._running = false;
|
|
24971
|
+
this.events.emit("pause");
|
|
24953
24972
|
return this;
|
|
24954
24973
|
}
|
|
24955
24974
|
/**
|
|
@@ -24957,6 +24976,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24957
24976
|
*/
|
|
24958
24977
|
resume() {
|
|
24959
24978
|
this._running = true;
|
|
24979
|
+
this.events.emit("resume");
|
|
24960
24980
|
return this;
|
|
24961
24981
|
}
|
|
24962
24982
|
/**
|
|
@@ -24971,6 +24991,8 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24971
24991
|
this._complete = false;
|
|
24972
24992
|
this._elapsedTime = 0;
|
|
24973
24993
|
this._numberOfTicks = 0;
|
|
24994
|
+
} else {
|
|
24995
|
+
this.events.emit("start");
|
|
24974
24996
|
}
|
|
24975
24997
|
return this;
|
|
24976
24998
|
}
|
|
@@ -24981,6 +25003,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24981
25003
|
this._running = false;
|
|
24982
25004
|
this._elapsedTime = 0;
|
|
24983
25005
|
this._numberOfTicks = 0;
|
|
25006
|
+
this.events.emit("stop");
|
|
24984
25007
|
return this;
|
|
24985
25008
|
}
|
|
24986
25009
|
/**
|
|
@@ -24990,6 +25013,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24990
25013
|
this.pause();
|
|
24991
25014
|
if (this.scene) {
|
|
24992
25015
|
this.scene.cancelTimer(this);
|
|
25016
|
+
this.events.emit("cancel");
|
|
24993
25017
|
}
|
|
24994
25018
|
}
|
|
24995
25019
|
};
|
|
@@ -33570,7 +33594,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33570
33594
|
this._count += count;
|
|
33571
33595
|
}
|
|
33572
33596
|
}
|
|
33573
|
-
const EX_VERSION = "0.32.0-alpha.
|
|
33597
|
+
const EX_VERSION = "0.32.0-alpha.1593+0f899e4";
|
|
33574
33598
|
polyfill();
|
|
33575
33599
|
exports2.ActionCompleteEvent = ActionCompleteEvent;
|
|
33576
33600
|
exports2.ActionContext = ActionContext;
|
|
@@ -33869,6 +33893,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33869
33893
|
exports2.TiledAnimation = TiledAnimation;
|
|
33870
33894
|
exports2.TiledSprite = TiledSprite;
|
|
33871
33895
|
exports2.Timer = Timer;
|
|
33896
|
+
exports2.TimerEvents = TimerEvents;
|
|
33872
33897
|
exports2.Toaster = Toaster;
|
|
33873
33898
|
exports2.Transform = Transform;
|
|
33874
33899
|
exports2.TransformComponent = TransformComponent;
|
package/build/dist/excalibur.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! excalibur - 0.32.0-alpha.
|
|
1
|
+
/*! excalibur - 0.32.0-alpha.1593+0f899e4 - 2025-12-6
|
|
2
2
|
https://github.com/excaliburjs/Excalibur
|
|
3
3
|
Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
|
|
4
4
|
Licensed BSD-2-Clause
|
|
@@ -24804,10 +24804,20 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24804
24804
|
return super.contains(coords.x, coords.y);
|
|
24805
24805
|
}
|
|
24806
24806
|
}
|
|
24807
|
+
const TimerEvents = {
|
|
24808
|
+
Start: "start",
|
|
24809
|
+
Stop: "stop",
|
|
24810
|
+
Pause: "pause",
|
|
24811
|
+
Resume: "resume",
|
|
24812
|
+
Cancel: "cancel",
|
|
24813
|
+
Action: "action",
|
|
24814
|
+
Complete: "complete"
|
|
24815
|
+
};
|
|
24807
24816
|
const _Timer = class _Timer2 {
|
|
24808
24817
|
constructor(options) {
|
|
24809
24818
|
this._logger = Logger.getInstance();
|
|
24810
24819
|
this.id = 0;
|
|
24820
|
+
this.events = new EventEmitter();
|
|
24811
24821
|
this._elapsedTime = 0;
|
|
24812
24822
|
this._totalTimeAlive = 0;
|
|
24813
24823
|
this._running = false;
|
|
@@ -24820,15 +24830,18 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24820
24830
|
this._generateRandomInterval = () => {
|
|
24821
24831
|
return this._baseInterval + this.random.integer(this.randomRange[0], this.randomRange[1]);
|
|
24822
24832
|
};
|
|
24833
|
+
this._onComplete = () => {
|
|
24834
|
+
};
|
|
24823
24835
|
this._complete = false;
|
|
24824
24836
|
this.scene = null;
|
|
24825
|
-
var _a;
|
|
24837
|
+
var _a, _b;
|
|
24826
24838
|
const fcn = (_a = options.action) != null ? _a : options.fcn;
|
|
24827
24839
|
const interval = options.interval;
|
|
24828
24840
|
const repeats = options.repeats;
|
|
24829
24841
|
const numberOfRepeats = options.numberOfRepeats;
|
|
24830
24842
|
const randomRange = options.randomRange;
|
|
24831
24843
|
const random = options.random;
|
|
24844
|
+
this._onComplete = (_b = options.onComplete) != null ? _b : this._onComplete;
|
|
24832
24845
|
if (!!numberOfRepeats && numberOfRepeats >= 0) {
|
|
24833
24846
|
this.maxNumberOfRepeats = numberOfRepeats;
|
|
24834
24847
|
if (!repeats) {
|
|
@@ -24884,18 +24897,23 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24884
24897
|
this._complete = true;
|
|
24885
24898
|
this._running = false;
|
|
24886
24899
|
this._elapsedTime = 0;
|
|
24900
|
+
this._onComplete();
|
|
24901
|
+
this.events.emit("complete");
|
|
24887
24902
|
}
|
|
24888
24903
|
if (!this.complete && this._elapsedTime >= this.interval) {
|
|
24889
24904
|
this._callbacks.forEach((c) => {
|
|
24890
24905
|
c.call(this);
|
|
24891
24906
|
});
|
|
24892
24907
|
this._numberOfTicks++;
|
|
24908
|
+
this.events.emit("action");
|
|
24893
24909
|
if (this.repeats) {
|
|
24894
24910
|
this._elapsedTime = 0;
|
|
24895
24911
|
} else {
|
|
24896
24912
|
this._complete = true;
|
|
24897
24913
|
this._running = false;
|
|
24898
24914
|
this._elapsedTime = 0;
|
|
24915
|
+
this._onComplete();
|
|
24916
|
+
this.events.emit("complete");
|
|
24899
24917
|
}
|
|
24900
24918
|
}
|
|
24901
24919
|
}
|
|
@@ -24950,6 +24968,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24950
24968
|
*/
|
|
24951
24969
|
pause() {
|
|
24952
24970
|
this._running = false;
|
|
24971
|
+
this.events.emit("pause");
|
|
24953
24972
|
return this;
|
|
24954
24973
|
}
|
|
24955
24974
|
/**
|
|
@@ -24957,6 +24976,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24957
24976
|
*/
|
|
24958
24977
|
resume() {
|
|
24959
24978
|
this._running = true;
|
|
24979
|
+
this.events.emit("resume");
|
|
24960
24980
|
return this;
|
|
24961
24981
|
}
|
|
24962
24982
|
/**
|
|
@@ -24971,6 +24991,8 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24971
24991
|
this._complete = false;
|
|
24972
24992
|
this._elapsedTime = 0;
|
|
24973
24993
|
this._numberOfTicks = 0;
|
|
24994
|
+
} else {
|
|
24995
|
+
this.events.emit("start");
|
|
24974
24996
|
}
|
|
24975
24997
|
return this;
|
|
24976
24998
|
}
|
|
@@ -24981,6 +25003,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24981
25003
|
this._running = false;
|
|
24982
25004
|
this._elapsedTime = 0;
|
|
24983
25005
|
this._numberOfTicks = 0;
|
|
25006
|
+
this.events.emit("stop");
|
|
24984
25007
|
return this;
|
|
24985
25008
|
}
|
|
24986
25009
|
/**
|
|
@@ -24990,6 +25013,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24990
25013
|
this.pause();
|
|
24991
25014
|
if (this.scene) {
|
|
24992
25015
|
this.scene.cancelTimer(this);
|
|
25016
|
+
this.events.emit("cancel");
|
|
24993
25017
|
}
|
|
24994
25018
|
}
|
|
24995
25019
|
};
|
|
@@ -33570,7 +33594,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33570
33594
|
this._count += count;
|
|
33571
33595
|
}
|
|
33572
33596
|
}
|
|
33573
|
-
const EX_VERSION = "0.32.0-alpha.
|
|
33597
|
+
const EX_VERSION = "0.32.0-alpha.1593+0f899e4";
|
|
33574
33598
|
polyfill();
|
|
33575
33599
|
exports2.ActionCompleteEvent = ActionCompleteEvent;
|
|
33576
33600
|
exports2.ActionContext = ActionContext;
|
|
@@ -33869,6 +33893,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33869
33893
|
exports2.TiledAnimation = TiledAnimation;
|
|
33870
33894
|
exports2.TiledSprite = TiledSprite;
|
|
33871
33895
|
exports2.Timer = Timer;
|
|
33896
|
+
exports2.TimerEvents = TimerEvents;
|
|
33872
33897
|
exports2.Toaster = Toaster;
|
|
33873
33898
|
exports2.Transform = Transform;
|
|
33874
33899
|
exports2.TransformComponent = TransformComponent;
|