eva-plugin-joystick
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -21,2 +21,3 @@ import { Component } from '@eva/eva.js'; | ||
private eventBinded; | ||
private pointerId; | ||
init(params: any): void; | ||
@@ -23,0 +24,0 @@ update(e: any): void; |
@@ -92,10 +92,10 @@ 'use strict'; | ||
if (this.triggerTouchstart) { | ||
this.emit(exports.JOYSTICK_EVENT.Begin, __assign(__assign({}, this.vector2), { event: e })); | ||
this.emit(exports.JOYSTICK_EVENT.Begin, __assign(__assign({}, this.vector2), { updateParams: e })); | ||
this.triggerTouchstart = false; | ||
} | ||
if (this.moving) { | ||
this.emit(exports.JOYSTICK_EVENT.Drag, __assign(__assign({}, this.vector2), { event: e })); | ||
this.emit(exports.JOYSTICK_EVENT.Drag, __assign(__assign({}, this.vector2), { updateParams: e })); | ||
} | ||
if (this.triggerTouchend) { | ||
this.emit(exports.JOYSTICK_EVENT.End, __assign(__assign({}, this.vector2), { event: e })); | ||
this.emit(exports.JOYSTICK_EVENT.End, __assign(__assign({}, this.vector2), { updateParams: e })); | ||
this.triggerTouchend = false; | ||
@@ -123,2 +123,3 @@ } | ||
this.evt.on('touchstart', function (e) { | ||
var _a; | ||
_this.moving = true; | ||
@@ -128,6 +129,10 @@ _this.basePosition.x = e.data.position.x; | ||
_this.triggerTouchstart = true; | ||
_this.pointerId = (_a = e.data) === null || _a === void 0 ? void 0 : _a.pointerId; | ||
}); | ||
this.evt.on('touchmove', function (e) { | ||
var _a; | ||
if (!_this.moving) | ||
return; | ||
if (undefined !== ((_a = e.data) === null || _a === void 0 ? void 0 : _a.pointerId) && _this.pointerId !== e.data.pointerId) | ||
return; | ||
var position = e.data.position; | ||
@@ -147,3 +152,6 @@ var vector2 = _this.vector2; | ||
}); | ||
var touchend = function () { | ||
var touchend = function (e) { | ||
var _a; | ||
if (undefined !== ((_a = e.data) === null || _a === void 0 ? void 0 : _a.pointerId) && _this.pointerId !== e.data.pointerId) | ||
return; | ||
_this.moving = false; | ||
@@ -219,2 +227,1 @@ _this.vector2.x = 0; | ||
exports.Joystick = Joystick; | ||
//# sourceMappingURL=plugin.cjs.js.map |
@@ -88,10 +88,10 @@ import { GameObject, resource, RESOURCE_TYPE, Component } from '@eva/eva.js'; | ||
if (this.triggerTouchstart) { | ||
this.emit(JOYSTICK_EVENT.Begin, __assign(__assign({}, this.vector2), { event: e })); | ||
this.emit(JOYSTICK_EVENT.Begin, __assign(__assign({}, this.vector2), { updateParams: e })); | ||
this.triggerTouchstart = false; | ||
} | ||
if (this.moving) { | ||
this.emit(JOYSTICK_EVENT.Drag, __assign(__assign({}, this.vector2), { event: e })); | ||
this.emit(JOYSTICK_EVENT.Drag, __assign(__assign({}, this.vector2), { updateParams: e })); | ||
} | ||
if (this.triggerTouchend) { | ||
this.emit(JOYSTICK_EVENT.End, __assign(__assign({}, this.vector2), { event: e })); | ||
this.emit(JOYSTICK_EVENT.End, __assign(__assign({}, this.vector2), { updateParams: e })); | ||
this.triggerTouchend = false; | ||
@@ -119,2 +119,3 @@ } | ||
this.evt.on('touchstart', function (e) { | ||
var _a; | ||
_this.moving = true; | ||
@@ -124,6 +125,10 @@ _this.basePosition.x = e.data.position.x; | ||
_this.triggerTouchstart = true; | ||
_this.pointerId = (_a = e.data) === null || _a === void 0 ? void 0 : _a.pointerId; | ||
}); | ||
this.evt.on('touchmove', function (e) { | ||
var _a; | ||
if (!_this.moving) | ||
return; | ||
if (undefined !== ((_a = e.data) === null || _a === void 0 ? void 0 : _a.pointerId) && _this.pointerId !== e.data.pointerId) | ||
return; | ||
var position = e.data.position; | ||
@@ -143,3 +148,6 @@ var vector2 = _this.vector2; | ||
}); | ||
var touchend = function () { | ||
var touchend = function (e) { | ||
var _a; | ||
if (undefined !== ((_a = e.data) === null || _a === void 0 ? void 0 : _a.pointerId) && _this.pointerId !== e.data.pointerId) | ||
return; | ||
_this.moving = false; | ||
@@ -215,2 +223,1 @@ _this.vector2.x = 0; | ||
export { JOYSTICK_EVENT, Joystick }; | ||
//# sourceMappingURL=plugin.esm.js.map |
@@ -680,10 +680,10 @@ this.EVA = this.EVA || {}; | ||
if (this.triggerTouchstart) { | ||
this.emit(exports.JOYSTICK_EVENT.Begin, __assign(__assign({}, this.vector2), { event: e })); | ||
this.emit(exports.JOYSTICK_EVENT.Begin, __assign(__assign({}, this.vector2), { updateParams: e })); | ||
this.triggerTouchstart = false; | ||
} | ||
if (this.moving) { | ||
this.emit(exports.JOYSTICK_EVENT.Drag, __assign(__assign({}, this.vector2), { event: e })); | ||
this.emit(exports.JOYSTICK_EVENT.Drag, __assign(__assign({}, this.vector2), { updateParams: e })); | ||
} | ||
if (this.triggerTouchend) { | ||
this.emit(exports.JOYSTICK_EVENT.End, __assign(__assign({}, this.vector2), { event: e })); | ||
this.emit(exports.JOYSTICK_EVENT.End, __assign(__assign({}, this.vector2), { updateParams: e })); | ||
this.triggerTouchend = false; | ||
@@ -711,2 +711,3 @@ } | ||
this.evt.on('touchstart', function (e) { | ||
var _a; | ||
_this.moving = true; | ||
@@ -716,6 +717,10 @@ _this.basePosition.x = e.data.position.x; | ||
_this.triggerTouchstart = true; | ||
_this.pointerId = (_a = e.data) === null || _a === void 0 ? void 0 : _a.pointerId; | ||
}); | ||
this.evt.on('touchmove', function (e) { | ||
var _a; | ||
if (!_this.moving) | ||
return; | ||
if (undefined !== ((_a = e.data) === null || _a === void 0 ? void 0 : _a.pointerId) && _this.pointerId !== e.data.pointerId) | ||
return; | ||
var position = e.data.position; | ||
@@ -735,3 +740,6 @@ var vector2 = _this.vector2; | ||
}); | ||
var touchend = function () { | ||
var touchend = function (e) { | ||
var _a; | ||
if (undefined !== ((_a = e.data) === null || _a === void 0 ? void 0 : _a.pointerId) && _this.pointerId !== e.data.pointerId) | ||
return; | ||
_this.moving = false; | ||
@@ -813,2 +821,1 @@ _this.vector2.x = 0; | ||
}({}, EVA, EVA.plugin.renderer, PIXI, EVA.rendererAdapter)); | ||
//# sourceMappingURL=plugin.global.js.map |
{ | ||
"name": "eva-plugin-joystick", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "rollup -c rollup.config.dev.js -w", |
@@ -94,2 +94,5 @@ # Eva.js Joystick | ||
``` | ||
### 事件名 | ||
参数为摇杆移动的二维向量,-1,1之间 | ||
@@ -107,2 +110,32 @@ | ||
摇杆结束事件 | ||
摇杆结束事件 | ||
### 回调函数参数 | ||
- x | ||
当前的joystick向量 x 值 -1 ~ 1 之间 | ||
- y | ||
当前的joystick向量 y 值 -1 ~ 1 之间 | ||
- updateParams | ||
当前update事件的参数 | ||
- deltaTime: number; | ||
每帧间隔时间,可以用于物体匀速运动 | ||
- frameCount: number; | ||
当前游戏总帧数 | ||
- currentTime: number; | ||
当前游戏时间 | ||
- fps: number; | ||
当前游戏帧率 |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
8529
139
0
377393
18
3