@vpmedia/phaser 1.0.19 → 1.0.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpmedia/phaser",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2",
5
5
  "author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
6
6
  "license": "MIT",
@@ -5,17 +5,8 @@
5
5
  */
6
6
  import Point from '../geom/point';
7
7
  import Circle from '../geom/circle';
8
- import DeviceButton from './input_button';
9
8
  import { POINTER, POINTER_CURSOR, POINTER_CONTACT, MOUSE_OVERRIDES_TOUCH, TOUCH_OVERRIDES_MOUSE, MOUSE_TOUCH_COMBINE } from './const';
10
9
 
11
- const NO_BUTTON = 0;
12
- const LEFT_BUTTON = 1;
13
- const RIGHT_BUTTON = 2;
14
- const MIDDLE_BUTTON = 4;
15
- const BACK_BUTTON = 8;
16
- const FORWARD_BUTTON = 16;
17
- const ERASER_BUTTON = 32;
18
-
19
10
  export default class {
20
11
 
21
12
  constructor(game, id, pointerMode) {
@@ -28,12 +19,6 @@ export default class {
28
19
  this.pointerMode = pointerMode || (POINTER_CURSOR | POINTER_CONTACT);
29
20
  this.target = null;
30
21
  this.button = null;
31
- this.leftButton = new DeviceButton(this, LEFT_BUTTON);
32
- this.rightButton = new DeviceButton(this, RIGHT_BUTTON);
33
- this.middleButton = new DeviceButton(this, MIDDLE_BUTTON);
34
- this.backButton = new DeviceButton(this, BACK_BUTTON);
35
- this.forwardButton = new DeviceButton(this, FORWARD_BUTTON);
36
- this.eraserButton = new DeviceButton(this, ERASER_BUTTON);
37
22
  this._holdSent = false;
38
23
  this._history = [];
39
24
  this._nextDrop = 0;
@@ -74,9 +59,6 @@ export default class {
74
59
  resetButtons() {
75
60
  this.isDown = false;
76
61
  this.isUp = true;
77
- if (this.isMouse) {
78
- this.leftButton.reset();
79
- }
80
62
  }
81
63
 
82
64
  updateButtons(event) {
@@ -13,6 +13,7 @@ export default class {
13
13
  this.game = game;
14
14
  this.onSoundDecode = new Signal();
15
15
  this.onVolumeChange = new Signal();
16
+ this.onLockChange = new Signal();
16
17
  this.onMute = new Signal();
17
18
  this.onUnMute = new Signal();
18
19
  this.context = null;
@@ -76,8 +77,11 @@ export default class {
76
77
  this.addUnlockHandlers();
77
78
  }
78
79
  this.context.addEventListener('statechange', () => {
80
+ this.onLockChange.dispatch('onContextStateChange', { state: this.context.state, isLocked: this.isLocked });
79
81
  if (this.isUnlockNeeded()) {
80
82
  this.addUnlockHandlers();
83
+ } else if (this.isLocked) {
84
+ this.removeUnlockHandlers();
81
85
  }
82
86
  });
83
87
  }
@@ -87,30 +91,36 @@ export default class {
87
91
  }
88
92
 
89
93
  addUnlockHandlers() {
94
+ this.isLocked = true;
95
+ this.onLockChange.dispatch('addUnlockHandlers', { state: this.context.state, isLocked: this.isLocked });
90
96
  document.body.addEventListener('touchstart', this.onUnlockEventBinded, false);
91
97
  document.body.addEventListener('touchend', this.onUnlockEventBinded, false);
92
98
  document.body.addEventListener('click', this.onUnlockEventBinded, false);
93
99
  document.body.addEventListener('keydown', this.onUnlockEventBinded, false);
94
- this.isLocked = true;
95
100
  }
96
101
 
97
102
  removeUnlockHandlers() {
103
+ this.isLocked = false;
104
+ this.onLockChange.dispatch('removeUnlockHandlers', { state: this.context.state, isLocked: this.isLocked });
98
105
  document.body.removeEventListener('touchstart', this.onUnlockEventBinded);
99
106
  document.body.removeEventListener('touchend', this.onUnlockEventBinded);
100
107
  document.body.removeEventListener('click', this.onUnlockEventBinded);
101
108
  document.body.removeEventListener('keydown', this.onUnlockEventBinded);
102
- this.isLocked = false;
103
109
  }
104
110
 
105
- onUnlockEvent() {
111
+ onUnlockEvent(event) {
112
+ const initialState = this.context.state;
106
113
  if (!this.isUnlockNeeded()) {
114
+ this.onLockChange.dispatch('onUnlockResumeDenied', { state: this.context.state, isLocked: this.isLocked, event });
107
115
  this.removeUnlockHandlers();
108
116
  return;
109
117
  }
110
- const initialState = this.context.state;
118
+ this.onLockChange.dispatch('onContextResumeStart', { state: this.context.state, isLocked: this.isLocked, event });
111
119
  this.context.resume().then(() => {
120
+ this.onLockChange.dispatch('onContextResumeResult', { state: this.context.state, isLocked: this.isLocked });
112
121
  this.removeUnlockHandlers();
113
122
  }).catch((e) => {
123
+ this.onLockChange.dispatch('onContextResumeReject', { state: this.context.state, isLocked: this.isLocked, error: e });
114
124
  this.removeUnlockHandlers();
115
125
  this.game.exceptionHandler(e, { initialState, state: this.context.state });
116
126
  });