@remvst/game-navigation-core 1.2.0 → 1.3.0

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.
@@ -2,6 +2,9 @@ import { GamePlugin } from "../game/game-plugin";
2
2
  export declare class BlurPausingGamePlugin extends GamePlugin {
3
3
  static readonly key = "blur-pausing-game";
4
4
  readonly key = "blur-pausing-game";
5
+ private _enabled;
6
+ get enabled(): boolean;
7
+ set enabled(enabled: boolean);
5
8
  setup(): void;
6
- private focusChanged;
9
+ private updateLoop;
7
10
  }
@@ -6,14 +6,22 @@ class BlurPausingGamePlugin extends game_plugin_1.GamePlugin {
6
6
  constructor() {
7
7
  super(...arguments);
8
8
  this.key = BlurPausingGamePlugin.key;
9
+ this._enabled = false;
10
+ }
11
+ get enabled() {
12
+ return this._enabled;
13
+ }
14
+ set enabled(enabled) {
15
+ this._enabled = enabled;
16
+ this.updateLoop();
9
17
  }
10
18
  setup() {
11
19
  super.setup();
12
- window.addEventListener('blur', () => this.focusChanged(), false);
13
- window.addEventListener('focus', () => this.focusChanged(), false);
20
+ window.addEventListener('blur', () => this.updateLoop(), false);
21
+ window.addEventListener('focus', () => this.updateLoop(), false);
14
22
  }
15
- focusChanged() {
16
- if (document.hasFocus()) {
23
+ updateLoop() {
24
+ if (document.hasFocus() || !this._enabled) {
17
25
  this.game.scheduleFrame();
18
26
  }
19
27
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remvst/game-navigation-core",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  "author": "Rémi Vansteelandt",
11
11
  "license": "UNLICENSED",
12
12
  "dependencies": {
13
- "@remvst/animate.js": "^2.0.0",
13
+ "@remvst/animate.js": "^3.0.0",
14
14
  "@remvst/client-inputs": "^1.0.4",
15
15
  "@remvst/client-performance": "^1.0.0",
16
16
  "@remvst/optimization": "^1.0.1"
@@ -5,15 +5,26 @@ export class BlurPausingGamePlugin extends GamePlugin {
5
5
  static readonly key = 'blur-pausing-game';
6
6
  readonly key = BlurPausingGamePlugin.key;
7
7
 
8
+ private _enabled = false;
9
+
10
+ get enabled() {
11
+ return this._enabled;
12
+ }
13
+
14
+ set enabled(enabled: boolean) {
15
+ this._enabled = enabled;
16
+ this.updateLoop();
17
+ }
18
+
8
19
  setup(): void {
9
20
  super.setup();
10
21
 
11
- window.addEventListener('blur', () => this.focusChanged(), false);
12
- window.addEventListener('focus', () => this.focusChanged(), false);
22
+ window.addEventListener('blur', () => this.updateLoop(), false);
23
+ window.addEventListener('focus', () => this.updateLoop(), false);
13
24
  }
14
25
 
15
- private focusChanged() {
16
- if (document.hasFocus()) {
26
+ private updateLoop() {
27
+ if (document.hasFocus() || !this._enabled) {
17
28
  this.game.scheduleFrame();
18
29
  } else {
19
30
  this.game.stopLoop();