react-simple-game-engine 0.2.6 → 0.2.10

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.
@@ -92,10 +92,10 @@ var Scaler = /** @class */ (function () {
92
92
  Scaler.prototype.update = function () {
93
93
  if (this._layoutMode === LayoutMode.LANDSCAPE) {
94
94
  if (this._canvasSize.width >= this._canvasSize.height) {
95
- this._value = this._canvasSize.height / this._gameSize.height;
95
+ this._value = this._canvasSize.width / this._gameSize.width;
96
96
  }
97
97
  else {
98
- this._value = this._canvasSize.width / this._gameSize.width;
98
+ this._value = this._canvasSize.height / this._gameSize.height;
99
99
  }
100
100
  }
101
101
  else {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="p5" />
2
- import { ComponentType } from "react";
2
+ import { ComponentType, ReactNode } from "react";
3
3
  import { Camera } from "./camera";
4
4
  import { LogicComponent } from "./logic-component";
5
5
  import { SceneManagement } from "./scene-management";
@@ -8,14 +8,26 @@ import { Prefab } from "./prefab";
8
8
  import { Sound } from "./sound";
9
9
  import { Avatar, GetSoundOptions, SoundManagement } from "../export-types";
10
10
  import { SoundType } from "../export-enums";
11
+ declare type AssetErrorType = "load-sound" | "load-sprite" | "load-extends";
12
+ export declare type AssetsFailBehavior = {
13
+ skip: true;
14
+ render?: never;
15
+ } | {
16
+ skip?: false;
17
+ render: (errors: {
18
+ type: AssetErrorType;
19
+ detail: any;
20
+ }[]) => ReactNode;
21
+ };
11
22
  declare type SoundOptionsChangeListener<O extends SoundType> = (options: SoundManagement[O]) => void;
12
23
  declare type LoadAssetsListener = (loadedAssets: boolean) => void;
13
24
  declare type EntityPropsChangeListener<V = any> = (value: V) => void;
14
- declare type ProcessStateChangeListener<V = any> = (isForeground: boolean) => void;
25
+ declare type ProcessStateChangeListener = (isForeground: boolean) => void;
15
26
  export declare abstract class Scene<UIP = any> {
16
27
  private ui;
17
28
  private worldManagement;
18
29
  private _loadedAssets;
30
+ private _renderAssetsFail;
19
31
  private loadAssetsListener;
20
32
  private nativeEventsUnsubscribes;
21
33
  private readonly entityPropsChangeListeners;
@@ -33,6 +45,7 @@ export declare abstract class Scene<UIP = any> {
33
45
  manager: SceneManagement;
34
46
  abstract getComponents(camera: Camera): LogicComponent<EntitySult>[];
35
47
  constructor();
48
+ get renderAssetsFail(): () => ReactNode;
36
49
  get UI(): ComponentType<UIP> | (() => any);
37
50
  get UIProps(): UIP;
38
51
  get soundBackgroundOptions(): SoundManagement[SoundType.BACKGROUND];
@@ -66,7 +79,7 @@ export declare abstract class Scene<UIP = any> {
66
79
  })[]): Promise<Sound[]>;
67
80
  mapSprites(...srcs: string[]): Promise<void>;
68
81
  mapSounds(...srcs: string[]): Promise<void>;
69
- loadAssets(delay?: number): Promise<void>;
82
+ loadAssets(delay: number | undefined | null, { skip, render }?: AssetsFailBehavior): Promise<void>;
70
83
  onLoadAssets(): Promise<void>;
71
84
  getPrefab<C extends EntitySult>(Class: {
72
85
  new (...args: any[]): Prefab<C>;
@@ -1 +1 @@
1
- {"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../../src/classes/scene.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AASlC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EACL,MAAM,EACN,eAAe,EAEf,eAAe,EAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,aAAK,0BAA0B,CAAC,CAAC,SAAS,SAAS,IAAI,CACrD,OAAO,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,CAAC,GAAG,EAAE,MAAM;YAIX,WAAW;YAcX,UAAU;IAcxB,aAAa,CAAC,GAAG,QAAQ,EAAE,CAAC,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE;IAcjD,YAAY,CAChB,GAAG,QAAQ,EAAE,CAAC,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,EAAE;IAsBxE,UAAU,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAgB5B,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE;IAc3B,UAAU,CACd,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAChC,EAAE,IAAY,EAAE,MAAM,EAAE,qBAA2B;IA8C/C,YAAY;IAElB,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,KAAK,EAAE;QACrC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;KACjC,GAAG,MAAM,CAAC,CAAC,CAAC;IAIb,kBAAkB;IAelB,SAAS,CAAC,MAAM,EAAE,MAAM;IAsCxB,SAAS,CAAC,MAAM;IAChB,SAAS,CAAC,QAAQ;IAElB,MAAM;CAUP"}
@@ -39,7 +39,6 @@ import { copyProperties, createAssetImage, createAssetSound, parallel, tick, } f
39
39
  import { Sound } from "./sound";
40
40
  import { SoundType } from "../export-enums";
41
41
  var MAX_ASSET_PARALLEL_LOAD = 4;
42
- var MAX_SOUND_PARALLEL_LOAD = 2;
43
42
  var Scene = /** @class */ (function () {
44
43
  function Scene() {
45
44
  this.nativeEventsUnsubscribes = function () { };
@@ -59,6 +58,13 @@ var Scene = /** @class */ (function () {
59
58
  this._loadedAssets = false;
60
59
  this.onBorn();
61
60
  }
61
+ Object.defineProperty(Scene.prototype, "renderAssetsFail", {
62
+ get: function () {
63
+ return this._renderAssetsFail;
64
+ },
65
+ enumerable: false,
66
+ configurable: true
67
+ });
62
68
  Object.defineProperty(Scene.prototype, "UI", {
63
69
  get: function () {
64
70
  var Ui = this.ui || (function () { return null; });
@@ -196,45 +202,61 @@ var Scene = /** @class */ (function () {
196
202
  this.manager.gotoScene(tag);
197
203
  };
198
204
  Scene.prototype.loadSprites = function () {
199
- var _this_1 = this;
200
- return parallel(this.spritesDecor, function (decor) { return __awaiter(_this_1, void 0, void 0, function () {
201
- var sprite;
205
+ return __awaiter(this, void 0, void 0, function () {
206
+ var _this_1 = this;
202
207
  return __generator(this, function (_a) {
203
208
  switch (_a.label) {
204
- case 0:
205
- if (!decor.src) return [3 /*break*/, 2];
206
- return [4 /*yield*/, createAssetImage(decor.src)];
209
+ case 0: return [4 /*yield*/, parallel(this.spritesDecor, function (decor) { return __awaiter(_this_1, void 0, void 0, function () {
210
+ var sprite;
211
+ return __generator(this, function (_a) {
212
+ switch (_a.label) {
213
+ case 0:
214
+ if (!decor.src) return [3 /*break*/, 2];
215
+ return [4 /*yield*/, createAssetImage(decor.src)];
216
+ case 1:
217
+ sprite = _a.sent();
218
+ this[decor.propertyKey] = sprite;
219
+ this.sprites.push(sprite);
220
+ _a.label = 2;
221
+ case 2: return [2 /*return*/];
222
+ }
223
+ });
224
+ }); }, MAX_ASSET_PARALLEL_LOAD)];
207
225
  case 1:
208
- sprite = _a.sent();
209
- this[decor.propertyKey] = sprite;
210
- this.sprites.push(sprite);
211
- _a.label = 2;
212
- case 2: return [2 /*return*/];
226
+ _a.sent();
227
+ return [2 /*return*/];
213
228
  }
214
229
  });
215
- }); }, MAX_ASSET_PARALLEL_LOAD);
230
+ });
216
231
  };
217
232
  Scene.prototype.loadSounds = function () {
218
- var _this_1 = this;
219
- return parallel(this.soundsDecor, function (decor) { return __awaiter(_this_1, void 0, void 0, function () {
220
- var sound;
221
- return __generator(this, function (_a) {
222
- switch (_a.label) {
233
+ return __awaiter(this, void 0, void 0, function () {
234
+ var _i, _a, decor, sound;
235
+ return __generator(this, function (_b) {
236
+ switch (_b.label) {
223
237
  case 0:
224
- if (!decor.src) return [3 /*break*/, 2];
225
- return [4 /*yield*/, createAssetSound(decor.src, decor.type)];
238
+ _i = 0, _a = this.soundsDecor;
239
+ _b.label = 1;
226
240
  case 1:
227
- sound = _a.sent();
241
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
242
+ decor = _a[_i];
243
+ if (!decor.src) return [3 /*break*/, 3];
244
+ return [4 /*yield*/, createAssetSound(decor.src, decor.type)];
245
+ case 2:
246
+ sound = _b.sent();
228
247
  if (decor.volumn) {
229
248
  sound.volumn = decor.volumn;
230
249
  }
231
250
  this[decor.propertyKey] = sound;
232
251
  this.sounds.push(sound);
233
- _a.label = 2;
234
- case 2: return [2 /*return*/];
252
+ _b.label = 3;
253
+ case 3:
254
+ _i++;
255
+ return [3 /*break*/, 1];
256
+ case 4: return [2 /*return*/];
235
257
  }
236
258
  });
237
- }); }, MAX_SOUND_PARALLEL_LOAD);
259
+ });
238
260
  };
239
261
  Scene.prototype.createSprites = function () {
240
262
  var _this_1 = this;
@@ -258,30 +280,40 @@ var Scene = /** @class */ (function () {
258
280
  }); }, MAX_ASSET_PARALLEL_LOAD);
259
281
  };
260
282
  Scene.prototype.createSounds = function () {
261
- var _this_1 = this;
262
283
  var srcables = [];
263
284
  for (var _i = 0; _i < arguments.length; _i++) {
264
285
  srcables[_i] = arguments[_i];
265
286
  }
266
- return parallel(srcables, function (srcable) { return __awaiter(_this_1, void 0, void 0, function () {
267
- var _a, volumn, src, _b, type, sound;
268
- return __generator(this, function (_c) {
269
- switch (_c.label) {
287
+ return __awaiter(this, void 0, void 0, function () {
288
+ var sounds, _a, srcables_1, srcable, _b, volumn, src, _c, type, sound;
289
+ return __generator(this, function (_d) {
290
+ switch (_d.label) {
270
291
  case 0:
271
- _a = typeof srcable === "string"
292
+ sounds = [];
293
+ _a = 0, srcables_1 = srcables;
294
+ _d.label = 1;
295
+ case 1:
296
+ if (!(_a < srcables_1.length)) return [3 /*break*/, 4];
297
+ srcable = srcables_1[_a];
298
+ _b = typeof srcable === "string"
272
299
  ? { src: srcable, volumn: undefined, type: undefined }
273
- : srcable, volumn = _a.volumn, src = _a.src, _b = _a.type, type = _b === void 0 ? SoundType.ONCE : _b;
300
+ : srcable, volumn = _b.volumn, src = _b.src, _c = _b.type, type = _c === void 0 ? SoundType.ONCE : _c;
274
301
  return [4 /*yield*/, createAssetSound(src, type)];
275
- case 1:
276
- sound = _c.sent();
302
+ case 2:
303
+ sound = _d.sent();
277
304
  if (volumn) {
278
305
  sound.volumn = volumn;
279
306
  }
307
+ sounds.push(sound);
280
308
  this.sounds.push(sound);
281
- return [2 /*return*/, sound];
309
+ _d.label = 3;
310
+ case 3:
311
+ _a++;
312
+ return [3 /*break*/, 1];
313
+ case 4: return [2 /*return*/, sounds];
282
314
  }
283
315
  });
284
- }); }, MAX_SOUND_PARALLEL_LOAD);
316
+ });
285
317
  };
286
318
  Scene.prototype.mapSprites = function () {
287
319
  var srcs = [];
@@ -328,46 +360,41 @@ var Scene = /** @class */ (function () {
328
360
  srcs[_i] = arguments[_i];
329
361
  }
330
362
  return __awaiter(this, void 0, void 0, function () {
331
- var soundsDecor;
332
- var _this_1 = this;
333
- return __generator(this, function (_a) {
334
- switch (_a.label) {
363
+ var soundsDecor, index, _a, soundsDecor_1, decor, src, sound;
364
+ return __generator(this, function (_b) {
365
+ switch (_b.label) {
335
366
  case 0:
336
367
  soundsDecor = this.soundsDecor.filter(function (decor) { return !decor.src; });
337
- return [4 /*yield*/, parallel(srcs, function (src, _a) {
338
- var realIndex = _a.realIndex;
339
- return __awaiter(_this_1, void 0, void 0, function () {
340
- var decor, sound;
341
- return __generator(this, function (_b) {
342
- switch (_b.label) {
343
- case 0:
344
- decor = soundsDecor[realIndex];
345
- if (!decor) return [3 /*break*/, 2];
346
- return [4 /*yield*/, createAssetSound(src, decor.type)];
347
- case 1:
348
- sound = _b.sent();
349
- if (decor.volumn) {
350
- sound.volumn = decor.volumn;
351
- }
352
- this[decor.propertyKey] = sound;
353
- this.sounds.push(sound);
354
- _b.label = 2;
355
- case 2: return [2 /*return*/];
356
- }
357
- });
358
- });
359
- }, MAX_ASSET_PARALLEL_LOAD)];
368
+ index = 0;
369
+ _a = 0, soundsDecor_1 = soundsDecor;
370
+ _b.label = 1;
360
371
  case 1:
361
- _a.sent();
362
- return [2 /*return*/];
372
+ if (!(_a < soundsDecor_1.length)) return [3 /*break*/, 4];
373
+ decor = soundsDecor_1[_a];
374
+ src = srcs[index++];
375
+ return [4 /*yield*/, createAssetSound(src, decor.type)];
376
+ case 2:
377
+ sound = _b.sent();
378
+ if (decor.volumn) {
379
+ sound.volumn = decor.volumn;
380
+ }
381
+ this[decor.propertyKey] = sound;
382
+ this.sounds.push(sound);
383
+ _b.label = 3;
384
+ case 3:
385
+ _a++;
386
+ return [3 /*break*/, 1];
387
+ case 4: return [2 /*return*/];
363
388
  }
364
389
  });
365
390
  });
366
391
  };
367
- Scene.prototype.loadAssets = function (delay) {
392
+ Scene.prototype.loadAssets = function (delay, _a) {
393
+ var _b = _a === void 0 ? {} : _a, _c = _b.skip, skip = _c === void 0 ? false : _c, render = _b.render;
368
394
  return __awaiter(this, void 0, void 0, function () {
369
- return __generator(this, function (_a) {
370
- switch (_a.label) {
395
+ var result, hasErrors;
396
+ return __generator(this, function (_d) {
397
+ switch (_d.label) {
371
398
  case 0:
372
399
  if (delay != null) {
373
400
  this.assetsDelay = delay;
@@ -376,24 +403,45 @@ var Scene = /** @class */ (function () {
376
403
  return [4 /*yield*/, tick(this.assetsDelay < 0 ? undefined : this.assetsDelay)];
377
404
  case 1:
378
405
  // if delay less than 0, it will wait forever
379
- _a.sent();
406
+ _d.sent();
380
407
  this.loadedAssets = false;
381
- return [4 /*yield*/, this.loadSprites().catch(function (err) {
382
- console.warn("Load sprites fail", err.toString());
383
- })];
408
+ return [4 /*yield*/, Promise.all([
409
+ this.loadSounds().catch(function (err) {
410
+ return {
411
+ error: true,
412
+ type: "load-sound",
413
+ detail: err,
414
+ };
415
+ }),
416
+ this.loadSprites().catch(function (err) {
417
+ return {
418
+ error: true,
419
+ type: "load-sprite",
420
+ detail: err,
421
+ };
422
+ }),
423
+ this.onLoadAssets().catch(function (err) {
424
+ return {
425
+ error: true,
426
+ type: "load-extends",
427
+ detail: err,
428
+ };
429
+ }),
430
+ ])];
384
431
  case 2:
385
- _a.sent();
386
- return [4 /*yield*/, this.loadSounds().catch(function (err) {
387
- console.warn("Load sounds fail", err.toString());
388
- })];
389
- case 3:
390
- _a.sent();
391
- return [4 /*yield*/, this.onLoadAssets().catch(function (err) {
392
- console.warn("Load assets fail", err.toString());
393
- })];
394
- case 4:
395
- _a.sent();
396
- this.loadedAssets = true;
432
+ result = _d.sent();
433
+ hasErrors = result.some(function (rs) { return rs === null || rs === void 0 ? void 0 : rs.error; });
434
+ if (hasErrors && !skip) {
435
+ // this.loadedAssets = false;
436
+ this._renderAssetsFail = function () {
437
+ var errors = result.filter(function (rs) { return !!(rs === null || rs === void 0 ? void 0 : rs.error); });
438
+ return render(errors);
439
+ };
440
+ }
441
+ else {
442
+ // when dont have error or skip error
443
+ this.loadedAssets = true;
444
+ }
397
445
  return [2 /*return*/];
398
446
  }
399
447
  });
@@ -418,8 +466,29 @@ var Scene = /** @class */ (function () {
418
466
  };
419
467
  };
420
468
  Scene.prototype.bootstrap = function (camera) {
469
+ var _this_1 = this;
421
470
  this.listenNativeEvents();
422
471
  this.bootSoundOptions();
472
+ this.onProcessStateChangeListener(function (isForeground) {
473
+ if (isForeground) {
474
+ if (window.Renderer.running) {
475
+ for (var _i = 0, _a = _this_1.sounds; _i < _a.length; _i++) {
476
+ var sound = _a[_i];
477
+ // only resume background sounds
478
+ if (sound.type === SoundType.BACKGROUND) {
479
+ sound.resume();
480
+ }
481
+ }
482
+ }
483
+ }
484
+ else {
485
+ // pause all sounds
486
+ for (var _b = 0, _c = _this_1.sounds; _b < _c.length; _b++) {
487
+ var sound = _c[_b];
488
+ sound.pause();
489
+ }
490
+ }
491
+ });
423
492
  this.worldManagement = new WorldManagement(camera, this);
424
493
  var components = this.getComponents(camera);
425
494
  var layerIndex = 0;
@@ -1,13 +1,16 @@
1
1
  import { SoundType } from "../export-enums";
2
2
  import { SoundManagement } from "../export-types";
3
3
  export declare class Sound {
4
- private readonly type;
4
+ readonly type: SoundType;
5
5
  static Management: SoundManagement;
6
6
  readonly native: HTMLAudioElement;
7
7
  constructor(type?: SoundType);
8
8
  get volumn(): number;
9
9
  set volumn(vol: number);
10
+ get isStopped(): boolean;
10
11
  playNow(): Promise<void>;
12
+ pause(): Promise<void>;
13
+ resume(): Promise<void>;
11
14
  stop(): Promise<void>;
12
15
  play(): Promise<void>;
13
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sound.d.ts","sourceRoot":"","sources":["../../src/classes/sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,qBAAa,KAAK;IAWJ,OAAO,CAAC,QAAQ,CAAC,IAAI;IAVjC,MAAM,CAAC,UAAU,EAAE,eAAe,CAOhC;IACF,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAe;gBAEnB,IAAI,GAAE,SAA0B;IAE7D,IAAI,MAAM,IAIM,MAAM,CAFrB;IAED,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,EAErB;IAEK,OAAO;IAQP,IAAI;IAWJ,IAAI;CAYX"}
1
+ {"version":3,"file":"sound.d.ts","sourceRoot":"","sources":["../../src/classes/sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,qBAAa,KAAK;aAWY,IAAI,EAAE,SAAS;IAV3C,MAAM,CAAC,UAAU,EAAE,eAAe,CAOhC;IACF,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAe;gBAEpB,IAAI,GAAE,SAA0B;IAE5D,IAAI,MAAM,IAIM,MAAM,CAFrB;IAED,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,EAErB;IAED,IAAI,SAAS,YAEZ;IAEK,OAAO;IAQP,KAAK;IAIL,MAAM;IAQN,IAAI;IAQJ,IAAI;CAYX"}
@@ -53,6 +53,13 @@ var Sound = /** @class */ (function () {
53
53
  enumerable: false,
54
54
  configurable: true
55
55
  });
56
+ Object.defineProperty(Sound.prototype, "isStopped", {
57
+ get: function () {
58
+ return this.native.paused && this.native.currentTime === 0;
59
+ },
60
+ enumerable: false,
61
+ configurable: true
62
+ });
56
63
  Sound.prototype.playNow = function () {
57
64
  return __awaiter(this, void 0, void 0, function () {
58
65
  var canPlay;
@@ -71,17 +78,41 @@ var Sound = /** @class */ (function () {
71
78
  });
72
79
  });
73
80
  };
81
+ Sound.prototype.pause = function () {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ return __generator(this, function (_a) {
84
+ switch (_a.label) {
85
+ case 0: return [4 /*yield*/, this.native.pause()];
86
+ case 1:
87
+ _a.sent();
88
+ return [2 /*return*/];
89
+ }
90
+ });
91
+ });
92
+ };
93
+ Sound.prototype.resume = function () {
94
+ return __awaiter(this, void 0, void 0, function () {
95
+ return __generator(this, function (_a) {
96
+ switch (_a.label) {
97
+ case 0:
98
+ if (!!this.isStopped) return [3 /*break*/, 2];
99
+ if (!this.native.paused) return [3 /*break*/, 2];
100
+ return [4 /*yield*/, this.play()];
101
+ case 1:
102
+ _a.sent();
103
+ _a.label = 2;
104
+ case 2: return [2 /*return*/];
105
+ }
106
+ });
107
+ });
108
+ };
74
109
  Sound.prototype.stop = function () {
75
110
  return __awaiter(this, void 0, void 0, function () {
76
- var isStoped;
77
111
  return __generator(this, function (_a) {
78
- if (this.native.src) {
79
- isStoped = this.native.paused && this.native.currentTime === 0;
80
- if (!isStoped) {
81
- this.native.pause();
82
- this.native.currentTime = 0;
83
- this.native.loop = false;
84
- }
112
+ if (!this.isStopped) {
113
+ this.native.pause();
114
+ this.native.currentTime = 0;
115
+ this.native.loop = false;
85
116
  }
86
117
  return [2 /*return*/];
87
118
  });
@@ -1,16 +1,17 @@
1
1
  import { ComponentType, ReactNode } from "react";
2
- import { Scene } from "../classes/scene";
2
+ import { AssetsFailBehavior, Scene } from "../classes/scene";
3
3
  import { LayoutMode } from "../export-enums";
4
4
  export declare type SceneRunnerPublicProps = {
5
5
  width: number;
6
6
  height: number;
7
7
  assetsLoader?: ReactNode | ComponentType;
8
8
  assetsDelay?: number;
9
+ assetsFailBehavior?: AssetsFailBehavior;
9
10
  layoutMode?: LayoutMode;
10
11
  };
11
12
  declare type SceneRunnerProps = SceneRunnerPublicProps & {
12
13
  current: Scene;
13
14
  };
14
- export declare function SceneRunner({ assetsDelay, current, width, height, assetsLoader: AssetsLoader, layoutMode, }: SceneRunnerProps): JSX.Element;
15
+ export declare function SceneRunner({ width, height, current, layoutMode, assetsDelay, assetsFailBehavior, assetsLoader: AssetsLoader, }: SceneRunnerProps): JSX.Element;
15
16
  export {};
16
17
  //# sourceMappingURL=scene-runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scene-runner.d.ts","sourceRoot":"","sources":["../../src/ui-components/scene-runner.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,SAAS,EAKV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,aAAK,gBAAgB,GAAG,sBAAsB,GAAG;IAC/C,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,WAAW,EACX,OAAO,EACP,KAAK,EACL,MAAM,EACN,YAAY,EAAE,YAAY,EAC1B,UAAiC,GAClC,EAAE,gBAAgB,eAiHlB"}
1
+ {"version":3,"file":"scene-runner.d.ts","sourceRoot":"","sources":["../../src/ui-components/scene-runner.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,SAAS,EAKV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,aAAK,gBAAgB,GAAG,sBAAsB,GAAG;IAC/C,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,MAAM,EACN,OAAO,EACP,UAAiC,EAEjC,WAAW,EACX,kBAAkB,EAClB,YAAY,EAAE,YAAY,GAC3B,EAAE,gBAAgB,eAsHlB"}
@@ -16,7 +16,9 @@ import { useWindowSize } from "../utils";
16
16
  import { LayoutMode } from "../export-enums";
17
17
  import { Scaler } from "../classes/scaler";
18
18
  export function SceneRunner(_a) {
19
- var assetsDelay = _a.assetsDelay, current = _a.current, width = _a.width, height = _a.height, AssetsLoader = _a.assetsLoader, _b = _a.layoutMode, layoutMode = _b === void 0 ? LayoutMode.LANDSCAPE : _b;
19
+ var width = _a.width, height = _a.height, current = _a.current, _b = _a.layoutMode, layoutMode = _b === void 0 ? LayoutMode.LANDSCAPE : _b,
20
+ //
21
+ assetsDelay = _a.assetsDelay, assetsFailBehavior = _a.assetsFailBehavior, AssetsLoader = _a.assetsLoader;
20
22
  var windowSize = useWindowSize();
21
23
  var refScaler = useRef(new Scaler(windowSize, { width: width, height: height }, layoutMode));
22
24
  var _c = useState(false), isBootDone = _c[0], setBootDone = _c[1];
@@ -39,7 +41,8 @@ export function SceneRunner(_a) {
39
41
  refScaler.current.layoutMode = layoutMode;
40
42
  }, [layoutMode]);
41
43
  useEffect(function () {
42
- current.loadAssets(assetsDelay);
44
+ current.loadAssets(assetsDelay, assetsFailBehavior);
45
+ // Don't Dependency on assetsFailBehavior
43
46
  }, [current, assetsDelay]);
44
47
  var setup = function (camera) {
45
48
  current.bootstrap(camera);
@@ -77,7 +80,9 @@ export function SceneRunner(_a) {
77
80
  } }, { children: _jsx("div", __assign({ style: __assign({ width: width, height: height, transform: "scale(".concat(refScaler.current.value, ")"), transformOrigin: "left top", position: "relative" }, (function () {
78
81
  var deltaOfScaleForUI = refScaler.current.deltaOfScaleForUI;
79
82
  return { left: deltaOfScaleForUI.x, top: deltaOfScaleForUI.y };
80
- })()) }, { children: !current.loadedAssets ? (assetsLoader) : (_jsx(_Fragment, { children: isBootDone ? (_jsx("div", __assign({ style: {
83
+ })()) }, { children: !current.loadedAssets ? (_jsx(_Fragment, { children: current.renderAssetsFail
84
+ ? current.renderAssetsFail()
85
+ : assetsLoader })) : (_jsx(_Fragment, { children: isBootDone ? (_jsx("div", __assign({ style: {
81
86
  width: "100%",
82
87
  height: "100%",
83
88
  } }, { children: _jsx(current.UI, __assign({ scene: current }, current.UIProps)) }))) : (_jsx("div", {})) })) })) }))] })));
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,S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CAiChB;AAED,wBAAsB,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,oBAQxC;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAO5B;AAED,wBAAsB,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAC3C,KAAK,EAAE,CAAC,EAAE,EACV,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,CAAC,CAAC,EACtE,KAAK,SAAI,GACR,OAAO,CAAC,CAAC,EAAE,CAAC,CAkBd;AAED,wBAAgB,aAAa;;;EAiB5B"}
package/lib/utils.js CHANGED
@@ -65,38 +65,33 @@ export function createAssetSound(src, type) {
65
65
  media = new Sound(type);
66
66
  return [2 /*return*/, new Promise(function (res, rej) {
67
67
  media.native.onloadedmetadata = function () {
68
- var timer = setInterval(function () {
69
- if (media.native.duration != null) {
70
- res(media);
71
- clearInterval(timer);
72
- }
73
- else {
74
- console.warn(src, "Wait for duration");
75
- }
76
- }, 10);
68
+ if (media.native.duration != null) {
69
+ res(media);
70
+ }
71
+ else {
72
+ var timer_1 = setInterval(function () {
73
+ if (media.native.duration != null) {
74
+ res(media);
75
+ clearInterval(timer_1);
76
+ }
77
+ else {
78
+ console.warn(src, "Wait for duration");
79
+ }
80
+ }, 10);
81
+ }
77
82
  };
78
83
  media.native.onerror = function (e) {
79
84
  if (e instanceof Event) {
80
85
  var targetError = e.currentTarget.error;
81
- switch (targetError.code) {
82
- case targetError.MEDIA_ERR_ABORTED:
83
- console.warn("You aborted the video playback.");
84
- break;
85
- case targetError.MEDIA_ERR_NETWORK:
86
- console.warn("A network error caused the audio download to fail.");
87
- break;
88
- case targetError.MEDIA_ERR_DECODE:
89
- console.warn("The audio playback was aborted due to a corruption problem or because the video used features your browser did not support.");
90
- break;
91
- case targetError.MEDIA_ERR_SRC_NOT_SUPPORTED:
92
- console.warn(src, e.currentTarget.src, "The video audio not be loaded, either because the server or network failed or because the format is not supported.");
93
- break;
94
- default:
95
- console.warn("An unknown error occurred.");
96
- break;
97
- }
86
+ rej({
87
+ fullSrc: e.currentTarget.src,
88
+ src: src,
89
+ code: targetError.code,
90
+ });
91
+ }
92
+ else {
93
+ rej(e);
98
94
  }
99
- rej(e);
100
95
  };
101
96
  media.native.setAttribute("preload", "metadata");
102
97
  media.native.setAttribute("type", "audio/wav");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-game-engine",
3
- "version": "0.2.6",
3
+ "version": "0.2.10",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",