react-simple-game-engine 0.1.15 → 0.1.18

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.
@@ -149,9 +149,9 @@ var Entity = /** @class */ (function (_super) {
149
149
  for (var name_1 in this.timerJobListeners) {
150
150
  var _a = this.timerJobListeners[name_1], timeCounter = _a.timeCounter, interval = _a.interval, job = _a.job, defaultRun = _a.defaultRun;
151
151
  if (defaultRun || timeCounter / 1000 >= interval) {
152
- defaultRun = false;
153
152
  timeCounter = 0;
154
153
  job();
154
+ this.timerJobListeners[name_1].defaultRun = false;
155
155
  }
156
156
  timeCounter += Renderer.deltaTime;
157
157
  this.timerJobListeners[name_1].timeCounter = timeCounter;
@@ -1,19 +1,22 @@
1
1
  import { Scene } from "./scene";
2
+ declare type SceneClass = {
3
+ new (): Scene;
4
+ tag?: string;
5
+ };
2
6
  declare type ChangeSceneListener = (scene: Scene) => void;
3
7
  export declare class SceneManagement {
4
8
  private Scenes;
5
9
  private _currentScene;
6
10
  private changeSceneListener;
7
- static getTag(Scene: {
8
- tag?: string;
9
- }): string | undefined;
10
- constructor(Scenes: {
11
- new (): Scene;
12
- tag?: string;
13
- }[]);
11
+ static getTag(Scene: SceneClass): string | undefined;
12
+ constructor(Scenes: SceneClass[]);
14
13
  get currentScene(): Scene<any>;
15
14
  onChangeScene(func: ChangeSceneListener): void;
15
+ canNext(): boolean;
16
+ next(): void;
17
+ replay(): void;
16
18
  gotoScene(tag: string): void;
19
+ private startScene;
17
20
  }
18
21
  export {};
19
22
  //# sourceMappingURL=scene-management.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scene-management.d.ts","sourceRoot":"","sources":["../../src/classes/scene-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,aAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAClD,qBAAa,eAAe;IAOd,OAAO,CAAC,MAAM;IAN1B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,mBAAmB,CAAuB;IAClD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE;gBAIjB,MAAM,EAAE;QAAE,QAAQ,KAAK,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE;IAK7D,IAAI,YAAY,eAEf;IAED,aAAa,CAAC,IAAI,EAAE,mBAAmB;IAIvC,SAAS,CAAC,GAAG,EAAE,MAAM;CActB"}
1
+ {"version":3,"file":"scene-management.d.ts","sourceRoot":"","sources":["../../src/classes/scene-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,aAAK,UAAU,GAAG;IAAE,QAAQ,KAAK,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD,aAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAClD,qBAAa,eAAe;IAOd,OAAO,CAAC,MAAM;IAN1B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,mBAAmB,CAAuB;IAClD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU;gBAIX,MAAM,EAAE,UAAU,EAAE;IAKxC,IAAI,YAAY,eAEf;IAED,aAAa,CAAC,IAAI,EAAE,mBAAmB;IAIvC,OAAO;IAQP,IAAI;IAUJ,MAAM;IAIN,SAAS,CAAC,GAAG,EAAE,MAAM;IAarB,OAAO,CAAC,UAAU;CAMnB"}
@@ -17,22 +17,43 @@ var SceneManagement = /** @class */ (function () {
17
17
  SceneManagement.prototype.onChangeScene = function (func) {
18
18
  this.changeSceneListener = func;
19
19
  };
20
+ SceneManagement.prototype.canNext = function () {
21
+ var _this = this;
22
+ var currentIndex = this.Scenes.findIndex(function (Scene) { return _this._currentScene instanceof Scene; });
23
+ var NextScene = this.Scenes[currentIndex + 1];
24
+ return !!NextScene;
25
+ };
26
+ SceneManagement.prototype.next = function () {
27
+ var _this = this;
28
+ var currentIndex = this.Scenes.findIndex(function (Scene) { return _this._currentScene instanceof Scene; });
29
+ var NextScene = this.Scenes[currentIndex + 1];
30
+ if (NextScene) {
31
+ this.startScene(NextScene);
32
+ }
33
+ };
34
+ SceneManagement.prototype.replay = function () {
35
+ this.gotoScene(this._currentScene.tag);
36
+ };
20
37
  SceneManagement.prototype.gotoScene = function (tag) {
21
- var _a;
22
- for (var _i = 0, _b = this.Scenes; _i < _b.length; _i++) {
23
- var Scene_1 = _b[_i];
38
+ for (var _i = 0, _a = this.Scenes; _i < _a.length; _i++) {
39
+ var Scene_1 = _a[_i];
24
40
  var _tag = SceneManagement.getTag(Scene_1);
25
41
  if (_tag === tag) {
26
42
  if (this._currentScene) {
27
43
  this._currentScene.destructor();
28
44
  }
29
- this._currentScene = new Scene_1();
30
- this._currentScene.manager = this;
31
- (_a = this.changeSceneListener) === null || _a === void 0 ? void 0 : _a.call(this, this._currentScene);
45
+ this.startScene(Scene_1);
32
46
  break;
33
47
  }
34
48
  }
35
49
  };
50
+ SceneManagement.prototype.startScene = function (Scene) {
51
+ var _a;
52
+ this._currentScene = new Scene();
53
+ this._currentScene.manager = this;
54
+ (_a = this.changeSceneListener) === null || _a === void 0 ? void 0 : _a.call(this, this._currentScene);
55
+ Renderer.running = true;
56
+ };
36
57
  return SceneManagement;
37
58
  }());
38
59
  export { SceneManagement };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-game-engine",
3
- "version": "0.1.15",
3
+ "version": "0.1.18",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",