@wwawing/virtual-pad 3.10.0-beta.2 → 3.10.0-beta.5
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/lib/VirtualPad.js +13 -7
- package/package.json +2 -2
- package/src/VirtualPad.ts +20 -10
package/lib/VirtualPad.js
CHANGED
|
@@ -15,6 +15,7 @@ var VirtualPadMoveButtonCodes = [
|
|
|
15
15
|
"BUTTON_RIGHT",
|
|
16
16
|
"BUTTON_DOWN"
|
|
17
17
|
];
|
|
18
|
+
var VirtualPadMoveButtonsSet = new Set(VirtualPadMoveButtonCodes);
|
|
18
19
|
var VirtualPadStore = (function () {
|
|
19
20
|
function VirtualPadStore(buttons, firstVisible, buttonWrapper, moveButtons, onTouchStart, onTouchEnd) {
|
|
20
21
|
if (firstVisible === void 0) { firstVisible = false; }
|
|
@@ -159,16 +160,18 @@ var VirtualPadStore = (function () {
|
|
|
159
160
|
return "NONE";
|
|
160
161
|
};
|
|
161
162
|
VirtualPadStore.prototype.setTouchInfo = function (buttonType) {
|
|
162
|
-
|
|
163
|
+
var button = this._isTouchingButtons[buttonType];
|
|
164
|
+
if (!this._enabled || button === undefined) {
|
|
163
165
|
return;
|
|
164
166
|
}
|
|
165
|
-
|
|
167
|
+
button.next = true;
|
|
166
168
|
};
|
|
167
169
|
VirtualPadStore.prototype.clearTouchInfo = function (buttonType) {
|
|
168
|
-
|
|
170
|
+
var button = this._isTouchingButtons[buttonType];
|
|
171
|
+
if (!this._enabled || button === undefined) {
|
|
169
172
|
return;
|
|
170
173
|
}
|
|
171
|
-
|
|
174
|
+
button.next = false;
|
|
172
175
|
};
|
|
173
176
|
VirtualPadStore.prototype.allMoveClear = function () {
|
|
174
177
|
var _this = this;
|
|
@@ -181,13 +184,16 @@ var VirtualPadStore = (function () {
|
|
|
181
184
|
VirtualPadStore.prototype.allClear = function () {
|
|
182
185
|
var _this = this;
|
|
183
186
|
this._availableButtons.forEach(function (buttonCode) {
|
|
184
|
-
if (buttonCode !== undefined
|
|
185
|
-
_this._isTouchingButtons[buttonCode]
|
|
187
|
+
if (buttonCode !== undefined) {
|
|
188
|
+
var button = _this._isTouchingButtons[buttonCode];
|
|
189
|
+
if (button !== undefined) {
|
|
190
|
+
button.next = false;
|
|
191
|
+
}
|
|
186
192
|
}
|
|
187
193
|
});
|
|
188
194
|
};
|
|
189
195
|
VirtualPadStore.isMoveButton = function (buttonType) {
|
|
190
|
-
return
|
|
196
|
+
return VirtualPadMoveButtonsSet.has(buttonType);
|
|
191
197
|
};
|
|
192
198
|
VirtualPadStore.prototype.update = function () {
|
|
193
199
|
var _this = this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wwawing/virtual-pad",
|
|
3
|
-
"version": "3.10.0-beta.
|
|
3
|
+
"version": "3.10.0-beta.5",
|
|
4
4
|
"description": "WWA Wing Virtual Pad for mobile phone",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "7676baae27caefd7ab9219c156b80612f148f81e"
|
|
20
20
|
}
|
package/src/VirtualPad.ts
CHANGED
|
@@ -35,7 +35,12 @@ const VirtualPadMoveButtonCodes = [
|
|
|
35
35
|
"BUTTON_UP",
|
|
36
36
|
"BUTTON_RIGHT",
|
|
37
37
|
"BUTTON_DOWN"
|
|
38
|
-
];
|
|
38
|
+
] as const;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 移動ボタンかどうかの判定に使用します。
|
|
42
|
+
*/
|
|
43
|
+
const VirtualPadMoveButtonsSet = new Set<VirtualPadButtonCode>(VirtualPadMoveButtonCodes);
|
|
39
44
|
|
|
40
45
|
/**
|
|
41
46
|
* 仮想パッドの状態管理を行うクラスです。
|
|
@@ -279,11 +284,12 @@ export default class VirtualPadStore {
|
|
|
279
284
|
* @param buttonType
|
|
280
285
|
*/
|
|
281
286
|
public setTouchInfo(buttonType: VirtualPadButtonCode) {
|
|
282
|
-
|
|
287
|
+
const button = this._isTouchingButtons[buttonType];
|
|
288
|
+
if (!this._enabled || button === undefined) {
|
|
283
289
|
return;
|
|
284
290
|
}
|
|
285
291
|
|
|
286
|
-
|
|
292
|
+
button.next = true;
|
|
287
293
|
}
|
|
288
294
|
|
|
289
295
|
/**
|
|
@@ -291,11 +297,12 @@ export default class VirtualPadStore {
|
|
|
291
297
|
* @param buttonType
|
|
292
298
|
*/
|
|
293
299
|
public clearTouchInfo(buttonType: VirtualPadButtonCode) {
|
|
294
|
-
|
|
300
|
+
const button = this._isTouchingButtons[buttonType];
|
|
301
|
+
if (!this._enabled || button === undefined) {
|
|
295
302
|
return;
|
|
296
303
|
}
|
|
297
304
|
|
|
298
|
-
|
|
305
|
+
button.next = false;
|
|
299
306
|
}
|
|
300
307
|
|
|
301
308
|
/**
|
|
@@ -303,8 +310,8 @@ export default class VirtualPadStore {
|
|
|
303
310
|
*/
|
|
304
311
|
public allMoveClear(): void {
|
|
305
312
|
VirtualPadMoveButtonCodes.forEach((buttonCode) => {
|
|
306
|
-
if (this._availableButtons.includes(buttonCode
|
|
307
|
-
this.clearTouchInfo(buttonCode
|
|
313
|
+
if (this._availableButtons.includes(buttonCode)) {
|
|
314
|
+
this.clearTouchInfo(buttonCode);
|
|
308
315
|
}
|
|
309
316
|
});
|
|
310
317
|
}
|
|
@@ -314,8 +321,11 @@ export default class VirtualPadStore {
|
|
|
314
321
|
*/
|
|
315
322
|
public allClear(): void {
|
|
316
323
|
this._availableButtons.forEach((buttonCode) => {
|
|
317
|
-
if (buttonCode !== undefined
|
|
318
|
-
|
|
324
|
+
if (buttonCode !== undefined) {
|
|
325
|
+
const button = this._isTouchingButtons[buttonCode];
|
|
326
|
+
if (button !== undefined) {
|
|
327
|
+
button.next = false;
|
|
328
|
+
}
|
|
319
329
|
}
|
|
320
330
|
});
|
|
321
331
|
}
|
|
@@ -325,7 +335,7 @@ export default class VirtualPadStore {
|
|
|
325
335
|
* @param buttonType
|
|
326
336
|
*/
|
|
327
337
|
public static isMoveButton(buttonType: VirtualPadButtonCode): boolean {
|
|
328
|
-
return
|
|
338
|
+
return VirtualPadMoveButtonsSet.has(buttonType);
|
|
329
339
|
}
|
|
330
340
|
|
|
331
341
|
/**
|