@vpmedia/phaser 1.0.19 → 1.0.20

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.20",
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,6 +77,7 @@ 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();
81
83
  }
@@ -87,6 +89,7 @@ export default class {
87
89
  }
88
90
 
89
91
  addUnlockHandlers() {
92
+ this.onLockChange.dispatch('addUnlockHandlers', { state: this.context.state, isLocked: this.isLocked });
90
93
  document.body.addEventListener('touchstart', this.onUnlockEventBinded, false);
91
94
  document.body.addEventListener('touchend', this.onUnlockEventBinded, false);
92
95
  document.body.addEventListener('click', this.onUnlockEventBinded, false);
@@ -95,6 +98,7 @@ export default class {
95
98
  }
96
99
 
97
100
  removeUnlockHandlers() {
101
+ this.onLockChange.dispatch('removeUnlockHandlers', { state: this.context.state, isLocked: this.isLocked });
98
102
  document.body.removeEventListener('touchstart', this.onUnlockEventBinded);
99
103
  document.body.removeEventListener('touchend', this.onUnlockEventBinded);
100
104
  document.body.removeEventListener('click', this.onUnlockEventBinded);
@@ -102,15 +106,18 @@ export default class {
102
106
  this.isLocked = false;
103
107
  }
104
108
 
105
- onUnlockEvent() {
109
+ onUnlockEvent(event) {
110
+ this.onLockChange.dispatch('onUnlockEvent', { state: this.context.state, isLocked: this.isLocked, event });
106
111
  if (!this.isUnlockNeeded()) {
107
112
  this.removeUnlockHandlers();
108
113
  return;
109
114
  }
110
115
  const initialState = this.context.state;
111
116
  this.context.resume().then(() => {
117
+ this.onLockChange.dispatch('onContextResumeResult', { state: this.context.state, isLocked: this.isLocked });
112
118
  this.removeUnlockHandlers();
113
119
  }).catch((e) => {
120
+ this.onLockChange.dispatch('onContextResumeReject', { state: this.context.state, isLocked: this.isLocked, error: e });
114
121
  this.removeUnlockHandlers();
115
122
  this.game.exceptionHandler(e, { initialState, state: this.context.state });
116
123
  });