mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2024-12-26 11:48:29 +00:00
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
const mgr = cc.internal.inputManager;
|
|
const canvasPosition = {
|
|
left: 0,
|
|
top: 0,
|
|
width: window.innerWidth,
|
|
height: window.innerHeight
|
|
};
|
|
|
|
if (mgr) {
|
|
Object.assign(mgr, {
|
|
_updateCanvasBoundingRect () {},
|
|
|
|
registerSystemEvent (element) {
|
|
if(this._isRegisterEvent) return;
|
|
|
|
this._glView = cc.view;
|
|
let self = this;
|
|
|
|
//register touch event
|
|
let _touchEventsMap = {
|
|
onTouchStart: this.handleTouchesBegin,
|
|
onTouchMove: this.handleTouchesMove,
|
|
onTouchEnd: this.handleTouchesEnd,
|
|
onTouchCancel: this.handleTouchesCancel,
|
|
};
|
|
|
|
let registerTouchEvent = function (eventName) {
|
|
let handler = _touchEventsMap[eventName];
|
|
__globalAdapter[eventName](function (event) {
|
|
if (!event.changedTouches) return;
|
|
handler.call(self, self.getTouchesByEvent(event, canvasPosition));
|
|
});
|
|
};
|
|
|
|
for (let eventName in _touchEventsMap) {
|
|
registerTouchEvent(eventName);
|
|
}
|
|
|
|
this._isRegisterEvent = true;
|
|
},
|
|
});
|
|
} |