excalibur 0.32.0-alpha.1591 → 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/Graphics/SpriteSheet.d.ts +14 -1
- package/build/dist/Timer.d.ts +27 -0
- package/build/dist/excalibur.development.js +126 -3
- package/build/dist/excalibur.js +126 -3
- package/build/dist/excalibur.min.development.js +41 -41
- package/build/dist/excalibur.min.js +41 -41
- package/build/esm/excalibur.development.js +126 -3
- package/build/esm/excalibur.js +126 -3
- package/build/esm/excalibur.min.development.js +475 -388
- package/build/esm/excalibur.min.js +475 -388
- 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 {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ImageSource } from './ImageSource';
|
|
2
2
|
import type { SourceView } from './Sprite';
|
|
3
3
|
import { Sprite } from './Sprite';
|
|
4
4
|
import type { GraphicOptions } from './Graphic';
|
|
@@ -130,6 +130,19 @@ export declare class SpriteSheet {
|
|
|
130
130
|
* @param options
|
|
131
131
|
*/
|
|
132
132
|
getTiledSprite(x: number, y: number, options?: Partial<Omit<TiledSpriteOptions & GraphicOptions, 'image'>>): TiledSprite;
|
|
133
|
+
/**
|
|
134
|
+
* Returns a sprite that has a new backing image the exact size of the sprite that tha is a copy of the original sprite slice.
|
|
135
|
+
*
|
|
136
|
+
* Useful if you need to apply effects, manipulate, or mutate the image and you don't want to disturb the original sprite sheet.
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
getSpriteAsStandalone(x: number, y: number): Promise<Sprite>;
|
|
140
|
+
/**
|
|
141
|
+
* Returns a new image exact size and copy of the original sprite slice.
|
|
142
|
+
*
|
|
143
|
+
* Useful if you need to apply effects, manipulate, or mutate the image and you don't want to disturb the original sprite sheet.
|
|
144
|
+
*/
|
|
145
|
+
getSpriteAsImage(x: number, y: number): Promise<HTMLImageElement>;
|
|
133
146
|
/**
|
|
134
147
|
* Create a sprite sheet from a sparse set of {@apilink SourceView} rectangles
|
|
135
148
|
* @param options
|
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
|
|
@@ -11212,6 +11212,104 @@ Read more here: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL
|
|
|
11212
11212
|
}
|
|
11213
11213
|
throw Error(`Invalid sprite coordinates (${x}, ${y})`);
|
|
11214
11214
|
}
|
|
11215
|
+
/**
|
|
11216
|
+
* Returns a sprite that has a new backing image the exact size of the sprite that tha is a copy of the original sprite slice.
|
|
11217
|
+
*
|
|
11218
|
+
* Useful if you need to apply effects, manipulate, or mutate the image and you don't want to disturb the original sprite sheet.
|
|
11219
|
+
*
|
|
11220
|
+
*/
|
|
11221
|
+
async getSpriteAsStandalone(x, y) {
|
|
11222
|
+
if (x >= this.columns || x < 0) {
|
|
11223
|
+
throw Error(`No sprite exists in the SpriteSheet at (${x}, ${y}), x: ${x} should be between 0 and ${this.columns - 1} columns`);
|
|
11224
|
+
}
|
|
11225
|
+
if (y >= this.rows || y < 0) {
|
|
11226
|
+
throw Error(`No sprite exists in the SpriteSheet at (${x}, ${y}), y: ${y} should be between 0 and ${this.rows - 1} rows`);
|
|
11227
|
+
}
|
|
11228
|
+
const spriteIndex = x + y * this.columns;
|
|
11229
|
+
const sprite = this.sprites[spriteIndex];
|
|
11230
|
+
const cnv = document.createElement("canvas");
|
|
11231
|
+
const ctx = cnv.getContext("2d");
|
|
11232
|
+
cnv.width = sprite.width;
|
|
11233
|
+
cnv.height = sprite.height;
|
|
11234
|
+
if (!sprite) {
|
|
11235
|
+
throw Error(`Invalid sprite coordinates (${x}, ${y})`);
|
|
11236
|
+
}
|
|
11237
|
+
if (!ctx) {
|
|
11238
|
+
throw Error("Unable to create canvas context");
|
|
11239
|
+
}
|
|
11240
|
+
ctx.drawImage(
|
|
11241
|
+
sprite.image.image,
|
|
11242
|
+
sprite.sourceView.x,
|
|
11243
|
+
sprite.sourceView.y,
|
|
11244
|
+
sprite.sourceView.width,
|
|
11245
|
+
sprite.sourceView.height,
|
|
11246
|
+
0,
|
|
11247
|
+
0,
|
|
11248
|
+
sprite.sourceView.width,
|
|
11249
|
+
sprite.sourceView.height
|
|
11250
|
+
);
|
|
11251
|
+
const imgSrc = new ImageSource(cnv.toDataURL());
|
|
11252
|
+
await imgSrc.load();
|
|
11253
|
+
return new Sprite({
|
|
11254
|
+
image: imgSrc,
|
|
11255
|
+
sourceView: {
|
|
11256
|
+
x: 0,
|
|
11257
|
+
y: 0,
|
|
11258
|
+
width: sprite.width,
|
|
11259
|
+
height: sprite.height
|
|
11260
|
+
},
|
|
11261
|
+
destSize: {
|
|
11262
|
+
width: sprite.width,
|
|
11263
|
+
height: sprite.height
|
|
11264
|
+
}
|
|
11265
|
+
});
|
|
11266
|
+
}
|
|
11267
|
+
/**
|
|
11268
|
+
* Returns a new image exact size and copy of the original sprite slice.
|
|
11269
|
+
*
|
|
11270
|
+
* Useful if you need to apply effects, manipulate, or mutate the image and you don't want to disturb the original sprite sheet.
|
|
11271
|
+
*/
|
|
11272
|
+
async getSpriteAsImage(x, y) {
|
|
11273
|
+
if (x >= this.columns || x < 0) {
|
|
11274
|
+
throw Error(`No sprite exists in the SpriteSheet at (${x}, ${y}), x: ${x} should be between 0 and ${this.columns - 1} columns`);
|
|
11275
|
+
}
|
|
11276
|
+
if (y >= this.rows || y < 0) {
|
|
11277
|
+
throw Error(`No sprite exists in the SpriteSheet at (${x}, ${y}), y: ${y} should be between 0 and ${this.rows - 1} rows`);
|
|
11278
|
+
}
|
|
11279
|
+
const spriteIndex = x + y * this.columns;
|
|
11280
|
+
const sprite = this.sprites[spriteIndex];
|
|
11281
|
+
const cnv = document.createElement("canvas");
|
|
11282
|
+
const ctx = cnv.getContext("2d");
|
|
11283
|
+
cnv.width = sprite.width;
|
|
11284
|
+
cnv.height = sprite.height;
|
|
11285
|
+
if (!sprite) {
|
|
11286
|
+
throw Error(`Invalid sprite coordinates (${x}, ${y})`);
|
|
11287
|
+
}
|
|
11288
|
+
if (!ctx) {
|
|
11289
|
+
throw Error("Unable to create canvas context");
|
|
11290
|
+
}
|
|
11291
|
+
ctx.drawImage(
|
|
11292
|
+
sprite.image.image,
|
|
11293
|
+
sprite.sourceView.x,
|
|
11294
|
+
sprite.sourceView.y,
|
|
11295
|
+
sprite.sourceView.width,
|
|
11296
|
+
sprite.sourceView.height,
|
|
11297
|
+
0,
|
|
11298
|
+
0,
|
|
11299
|
+
sprite.sourceView.width,
|
|
11300
|
+
sprite.sourceView.height
|
|
11301
|
+
);
|
|
11302
|
+
const imgSrc = new Image(sprite.width, sprite.height);
|
|
11303
|
+
imgSrc.src = cnv.toDataURL();
|
|
11304
|
+
return await new Promise((resolve, reject) => {
|
|
11305
|
+
imgSrc.onload = () => {
|
|
11306
|
+
resolve(imgSrc);
|
|
11307
|
+
};
|
|
11308
|
+
imgSrc.onerror = (e) => {
|
|
11309
|
+
reject(e);
|
|
11310
|
+
};
|
|
11311
|
+
});
|
|
11312
|
+
}
|
|
11215
11313
|
/**
|
|
11216
11314
|
* Create a sprite sheet from a sparse set of {@apilink SourceView} rectangles
|
|
11217
11315
|
* @param options
|
|
@@ -24706,10 +24804,20 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24706
24804
|
return super.contains(coords.x, coords.y);
|
|
24707
24805
|
}
|
|
24708
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
|
+
};
|
|
24709
24816
|
const _Timer = class _Timer2 {
|
|
24710
24817
|
constructor(options) {
|
|
24711
24818
|
this._logger = Logger.getInstance();
|
|
24712
24819
|
this.id = 0;
|
|
24820
|
+
this.events = new EventEmitter();
|
|
24713
24821
|
this._elapsedTime = 0;
|
|
24714
24822
|
this._totalTimeAlive = 0;
|
|
24715
24823
|
this._running = false;
|
|
@@ -24722,15 +24830,18 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24722
24830
|
this._generateRandomInterval = () => {
|
|
24723
24831
|
return this._baseInterval + this.random.integer(this.randomRange[0], this.randomRange[1]);
|
|
24724
24832
|
};
|
|
24833
|
+
this._onComplete = () => {
|
|
24834
|
+
};
|
|
24725
24835
|
this._complete = false;
|
|
24726
24836
|
this.scene = null;
|
|
24727
|
-
var _a;
|
|
24837
|
+
var _a, _b;
|
|
24728
24838
|
const fcn = (_a = options.action) != null ? _a : options.fcn;
|
|
24729
24839
|
const interval = options.interval;
|
|
24730
24840
|
const repeats = options.repeats;
|
|
24731
24841
|
const numberOfRepeats = options.numberOfRepeats;
|
|
24732
24842
|
const randomRange = options.randomRange;
|
|
24733
24843
|
const random = options.random;
|
|
24844
|
+
this._onComplete = (_b = options.onComplete) != null ? _b : this._onComplete;
|
|
24734
24845
|
if (!!numberOfRepeats && numberOfRepeats >= 0) {
|
|
24735
24846
|
this.maxNumberOfRepeats = numberOfRepeats;
|
|
24736
24847
|
if (!repeats) {
|
|
@@ -24786,18 +24897,23 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24786
24897
|
this._complete = true;
|
|
24787
24898
|
this._running = false;
|
|
24788
24899
|
this._elapsedTime = 0;
|
|
24900
|
+
this._onComplete();
|
|
24901
|
+
this.events.emit("complete");
|
|
24789
24902
|
}
|
|
24790
24903
|
if (!this.complete && this._elapsedTime >= this.interval) {
|
|
24791
24904
|
this._callbacks.forEach((c) => {
|
|
24792
24905
|
c.call(this);
|
|
24793
24906
|
});
|
|
24794
24907
|
this._numberOfTicks++;
|
|
24908
|
+
this.events.emit("action");
|
|
24795
24909
|
if (this.repeats) {
|
|
24796
24910
|
this._elapsedTime = 0;
|
|
24797
24911
|
} else {
|
|
24798
24912
|
this._complete = true;
|
|
24799
24913
|
this._running = false;
|
|
24800
24914
|
this._elapsedTime = 0;
|
|
24915
|
+
this._onComplete();
|
|
24916
|
+
this.events.emit("complete");
|
|
24801
24917
|
}
|
|
24802
24918
|
}
|
|
24803
24919
|
}
|
|
@@ -24852,6 +24968,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24852
24968
|
*/
|
|
24853
24969
|
pause() {
|
|
24854
24970
|
this._running = false;
|
|
24971
|
+
this.events.emit("pause");
|
|
24855
24972
|
return this;
|
|
24856
24973
|
}
|
|
24857
24974
|
/**
|
|
@@ -24859,6 +24976,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24859
24976
|
*/
|
|
24860
24977
|
resume() {
|
|
24861
24978
|
this._running = true;
|
|
24979
|
+
this.events.emit("resume");
|
|
24862
24980
|
return this;
|
|
24863
24981
|
}
|
|
24864
24982
|
/**
|
|
@@ -24873,6 +24991,8 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24873
24991
|
this._complete = false;
|
|
24874
24992
|
this._elapsedTime = 0;
|
|
24875
24993
|
this._numberOfTicks = 0;
|
|
24994
|
+
} else {
|
|
24995
|
+
this.events.emit("start");
|
|
24876
24996
|
}
|
|
24877
24997
|
return this;
|
|
24878
24998
|
}
|
|
@@ -24883,6 +25003,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24883
25003
|
this._running = false;
|
|
24884
25004
|
this._elapsedTime = 0;
|
|
24885
25005
|
this._numberOfTicks = 0;
|
|
25006
|
+
this.events.emit("stop");
|
|
24886
25007
|
return this;
|
|
24887
25008
|
}
|
|
24888
25009
|
/**
|
|
@@ -24892,6 +25013,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24892
25013
|
this.pause();
|
|
24893
25014
|
if (this.scene) {
|
|
24894
25015
|
this.scene.cancelTimer(this);
|
|
25016
|
+
this.events.emit("cancel");
|
|
24895
25017
|
}
|
|
24896
25018
|
}
|
|
24897
25019
|
};
|
|
@@ -33472,7 +33594,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33472
33594
|
this._count += count;
|
|
33473
33595
|
}
|
|
33474
33596
|
}
|
|
33475
|
-
const EX_VERSION = "0.32.0-alpha.
|
|
33597
|
+
const EX_VERSION = "0.32.0-alpha.1593+0f899e4";
|
|
33476
33598
|
polyfill();
|
|
33477
33599
|
exports2.ActionCompleteEvent = ActionCompleteEvent;
|
|
33478
33600
|
exports2.ActionContext = ActionContext;
|
|
@@ -33771,6 +33893,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33771
33893
|
exports2.TiledAnimation = TiledAnimation;
|
|
33772
33894
|
exports2.TiledSprite = TiledSprite;
|
|
33773
33895
|
exports2.Timer = Timer;
|
|
33896
|
+
exports2.TimerEvents = TimerEvents;
|
|
33774
33897
|
exports2.Toaster = Toaster;
|
|
33775
33898
|
exports2.Transform = Transform;
|
|
33776
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
|
|
@@ -11212,6 +11212,104 @@ Read more here: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL
|
|
|
11212
11212
|
}
|
|
11213
11213
|
throw Error(`Invalid sprite coordinates (${x}, ${y})`);
|
|
11214
11214
|
}
|
|
11215
|
+
/**
|
|
11216
|
+
* Returns a sprite that has a new backing image the exact size of the sprite that tha is a copy of the original sprite slice.
|
|
11217
|
+
*
|
|
11218
|
+
* Useful if you need to apply effects, manipulate, or mutate the image and you don't want to disturb the original sprite sheet.
|
|
11219
|
+
*
|
|
11220
|
+
*/
|
|
11221
|
+
async getSpriteAsStandalone(x, y) {
|
|
11222
|
+
if (x >= this.columns || x < 0) {
|
|
11223
|
+
throw Error(`No sprite exists in the SpriteSheet at (${x}, ${y}), x: ${x} should be between 0 and ${this.columns - 1} columns`);
|
|
11224
|
+
}
|
|
11225
|
+
if (y >= this.rows || y < 0) {
|
|
11226
|
+
throw Error(`No sprite exists in the SpriteSheet at (${x}, ${y}), y: ${y} should be between 0 and ${this.rows - 1} rows`);
|
|
11227
|
+
}
|
|
11228
|
+
const spriteIndex = x + y * this.columns;
|
|
11229
|
+
const sprite = this.sprites[spriteIndex];
|
|
11230
|
+
const cnv = document.createElement("canvas");
|
|
11231
|
+
const ctx = cnv.getContext("2d");
|
|
11232
|
+
cnv.width = sprite.width;
|
|
11233
|
+
cnv.height = sprite.height;
|
|
11234
|
+
if (!sprite) {
|
|
11235
|
+
throw Error(`Invalid sprite coordinates (${x}, ${y})`);
|
|
11236
|
+
}
|
|
11237
|
+
if (!ctx) {
|
|
11238
|
+
throw Error("Unable to create canvas context");
|
|
11239
|
+
}
|
|
11240
|
+
ctx.drawImage(
|
|
11241
|
+
sprite.image.image,
|
|
11242
|
+
sprite.sourceView.x,
|
|
11243
|
+
sprite.sourceView.y,
|
|
11244
|
+
sprite.sourceView.width,
|
|
11245
|
+
sprite.sourceView.height,
|
|
11246
|
+
0,
|
|
11247
|
+
0,
|
|
11248
|
+
sprite.sourceView.width,
|
|
11249
|
+
sprite.sourceView.height
|
|
11250
|
+
);
|
|
11251
|
+
const imgSrc = new ImageSource(cnv.toDataURL());
|
|
11252
|
+
await imgSrc.load();
|
|
11253
|
+
return new Sprite({
|
|
11254
|
+
image: imgSrc,
|
|
11255
|
+
sourceView: {
|
|
11256
|
+
x: 0,
|
|
11257
|
+
y: 0,
|
|
11258
|
+
width: sprite.width,
|
|
11259
|
+
height: sprite.height
|
|
11260
|
+
},
|
|
11261
|
+
destSize: {
|
|
11262
|
+
width: sprite.width,
|
|
11263
|
+
height: sprite.height
|
|
11264
|
+
}
|
|
11265
|
+
});
|
|
11266
|
+
}
|
|
11267
|
+
/**
|
|
11268
|
+
* Returns a new image exact size and copy of the original sprite slice.
|
|
11269
|
+
*
|
|
11270
|
+
* Useful if you need to apply effects, manipulate, or mutate the image and you don't want to disturb the original sprite sheet.
|
|
11271
|
+
*/
|
|
11272
|
+
async getSpriteAsImage(x, y) {
|
|
11273
|
+
if (x >= this.columns || x < 0) {
|
|
11274
|
+
throw Error(`No sprite exists in the SpriteSheet at (${x}, ${y}), x: ${x} should be between 0 and ${this.columns - 1} columns`);
|
|
11275
|
+
}
|
|
11276
|
+
if (y >= this.rows || y < 0) {
|
|
11277
|
+
throw Error(`No sprite exists in the SpriteSheet at (${x}, ${y}), y: ${y} should be between 0 and ${this.rows - 1} rows`);
|
|
11278
|
+
}
|
|
11279
|
+
const spriteIndex = x + y * this.columns;
|
|
11280
|
+
const sprite = this.sprites[spriteIndex];
|
|
11281
|
+
const cnv = document.createElement("canvas");
|
|
11282
|
+
const ctx = cnv.getContext("2d");
|
|
11283
|
+
cnv.width = sprite.width;
|
|
11284
|
+
cnv.height = sprite.height;
|
|
11285
|
+
if (!sprite) {
|
|
11286
|
+
throw Error(`Invalid sprite coordinates (${x}, ${y})`);
|
|
11287
|
+
}
|
|
11288
|
+
if (!ctx) {
|
|
11289
|
+
throw Error("Unable to create canvas context");
|
|
11290
|
+
}
|
|
11291
|
+
ctx.drawImage(
|
|
11292
|
+
sprite.image.image,
|
|
11293
|
+
sprite.sourceView.x,
|
|
11294
|
+
sprite.sourceView.y,
|
|
11295
|
+
sprite.sourceView.width,
|
|
11296
|
+
sprite.sourceView.height,
|
|
11297
|
+
0,
|
|
11298
|
+
0,
|
|
11299
|
+
sprite.sourceView.width,
|
|
11300
|
+
sprite.sourceView.height
|
|
11301
|
+
);
|
|
11302
|
+
const imgSrc = new Image(sprite.width, sprite.height);
|
|
11303
|
+
imgSrc.src = cnv.toDataURL();
|
|
11304
|
+
return await new Promise((resolve, reject) => {
|
|
11305
|
+
imgSrc.onload = () => {
|
|
11306
|
+
resolve(imgSrc);
|
|
11307
|
+
};
|
|
11308
|
+
imgSrc.onerror = (e) => {
|
|
11309
|
+
reject(e);
|
|
11310
|
+
};
|
|
11311
|
+
});
|
|
11312
|
+
}
|
|
11215
11313
|
/**
|
|
11216
11314
|
* Create a sprite sheet from a sparse set of {@apilink SourceView} rectangles
|
|
11217
11315
|
* @param options
|
|
@@ -24706,10 +24804,20 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24706
24804
|
return super.contains(coords.x, coords.y);
|
|
24707
24805
|
}
|
|
24708
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
|
+
};
|
|
24709
24816
|
const _Timer = class _Timer2 {
|
|
24710
24817
|
constructor(options) {
|
|
24711
24818
|
this._logger = Logger.getInstance();
|
|
24712
24819
|
this.id = 0;
|
|
24820
|
+
this.events = new EventEmitter();
|
|
24713
24821
|
this._elapsedTime = 0;
|
|
24714
24822
|
this._totalTimeAlive = 0;
|
|
24715
24823
|
this._running = false;
|
|
@@ -24722,15 +24830,18 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24722
24830
|
this._generateRandomInterval = () => {
|
|
24723
24831
|
return this._baseInterval + this.random.integer(this.randomRange[0], this.randomRange[1]);
|
|
24724
24832
|
};
|
|
24833
|
+
this._onComplete = () => {
|
|
24834
|
+
};
|
|
24725
24835
|
this._complete = false;
|
|
24726
24836
|
this.scene = null;
|
|
24727
|
-
var _a;
|
|
24837
|
+
var _a, _b;
|
|
24728
24838
|
const fcn = (_a = options.action) != null ? _a : options.fcn;
|
|
24729
24839
|
const interval = options.interval;
|
|
24730
24840
|
const repeats = options.repeats;
|
|
24731
24841
|
const numberOfRepeats = options.numberOfRepeats;
|
|
24732
24842
|
const randomRange = options.randomRange;
|
|
24733
24843
|
const random = options.random;
|
|
24844
|
+
this._onComplete = (_b = options.onComplete) != null ? _b : this._onComplete;
|
|
24734
24845
|
if (!!numberOfRepeats && numberOfRepeats >= 0) {
|
|
24735
24846
|
this.maxNumberOfRepeats = numberOfRepeats;
|
|
24736
24847
|
if (!repeats) {
|
|
@@ -24786,18 +24897,23 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24786
24897
|
this._complete = true;
|
|
24787
24898
|
this._running = false;
|
|
24788
24899
|
this._elapsedTime = 0;
|
|
24900
|
+
this._onComplete();
|
|
24901
|
+
this.events.emit("complete");
|
|
24789
24902
|
}
|
|
24790
24903
|
if (!this.complete && this._elapsedTime >= this.interval) {
|
|
24791
24904
|
this._callbacks.forEach((c) => {
|
|
24792
24905
|
c.call(this);
|
|
24793
24906
|
});
|
|
24794
24907
|
this._numberOfTicks++;
|
|
24908
|
+
this.events.emit("action");
|
|
24795
24909
|
if (this.repeats) {
|
|
24796
24910
|
this._elapsedTime = 0;
|
|
24797
24911
|
} else {
|
|
24798
24912
|
this._complete = true;
|
|
24799
24913
|
this._running = false;
|
|
24800
24914
|
this._elapsedTime = 0;
|
|
24915
|
+
this._onComplete();
|
|
24916
|
+
this.events.emit("complete");
|
|
24801
24917
|
}
|
|
24802
24918
|
}
|
|
24803
24919
|
}
|
|
@@ -24852,6 +24968,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24852
24968
|
*/
|
|
24853
24969
|
pause() {
|
|
24854
24970
|
this._running = false;
|
|
24971
|
+
this.events.emit("pause");
|
|
24855
24972
|
return this;
|
|
24856
24973
|
}
|
|
24857
24974
|
/**
|
|
@@ -24859,6 +24976,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24859
24976
|
*/
|
|
24860
24977
|
resume() {
|
|
24861
24978
|
this._running = true;
|
|
24979
|
+
this.events.emit("resume");
|
|
24862
24980
|
return this;
|
|
24863
24981
|
}
|
|
24864
24982
|
/**
|
|
@@ -24873,6 +24991,8 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24873
24991
|
this._complete = false;
|
|
24874
24992
|
this._elapsedTime = 0;
|
|
24875
24993
|
this._numberOfTicks = 0;
|
|
24994
|
+
} else {
|
|
24995
|
+
this.events.emit("start");
|
|
24876
24996
|
}
|
|
24877
24997
|
return this;
|
|
24878
24998
|
}
|
|
@@ -24883,6 +25003,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24883
25003
|
this._running = false;
|
|
24884
25004
|
this._elapsedTime = 0;
|
|
24885
25005
|
this._numberOfTicks = 0;
|
|
25006
|
+
this.events.emit("stop");
|
|
24886
25007
|
return this;
|
|
24887
25008
|
}
|
|
24888
25009
|
/**
|
|
@@ -24892,6 +25013,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
|
|
|
24892
25013
|
this.pause();
|
|
24893
25014
|
if (this.scene) {
|
|
24894
25015
|
this.scene.cancelTimer(this);
|
|
25016
|
+
this.events.emit("cancel");
|
|
24895
25017
|
}
|
|
24896
25018
|
}
|
|
24897
25019
|
};
|
|
@@ -33472,7 +33594,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33472
33594
|
this._count += count;
|
|
33473
33595
|
}
|
|
33474
33596
|
}
|
|
33475
|
-
const EX_VERSION = "0.32.0-alpha.
|
|
33597
|
+
const EX_VERSION = "0.32.0-alpha.1593+0f899e4";
|
|
33476
33598
|
polyfill();
|
|
33477
33599
|
exports2.ActionCompleteEvent = ActionCompleteEvent;
|
|
33478
33600
|
exports2.ActionContext = ActionContext;
|
|
@@ -33771,6 +33893,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
|
|
|
33771
33893
|
exports2.TiledAnimation = TiledAnimation;
|
|
33772
33894
|
exports2.TiledSprite = TiledSprite;
|
|
33773
33895
|
exports2.Timer = Timer;
|
|
33896
|
+
exports2.TimerEvents = TimerEvents;
|
|
33774
33897
|
exports2.Toaster = Toaster;
|
|
33775
33898
|
exports2.Transform = Transform;
|
|
33776
33899
|
exports2.TransformComponent = TransformComponent;
|