Cocos Creator 3.5 调用 fgui.GRoot.create(); 之后,Creator的 input 事件监听不到。
如题。
新建个测试工程,测试代码如下:
无报错。
发现,调用了 fgui.GRoot.create(); 之后,
cocos creator的全局监听输入事件:
目前,我的解决方法是
在创建UI层级容器的时候,最上层,创建一个专门用于监听全局交互的层:
this._gameMain.interactionEventLayer = fgui.UIPackage.createObject(pakName,comName).asCom;
然后这个层专门监听交互事件:
this._gameMain.interactionEventLayer.node.on(Node.EventType.MOUSE_DOWN,this._gameMain.onMouseDown,this._gameMain);
这样暂时可以搞定我的业务需求,但似乎有点不雅。
新建个测试工程,测试代码如下:
start () {
fgui.GRoot.create();
input.on(Input.EventType.MOUSE_DOWN,this.onMouseDown,this);
};
public onMouseDown(evnet:any){
console.log("监听到MouseDown");
};
无报错。
发现,调用了 fgui.GRoot.create(); 之后,
cocos creator的全局监听输入事件:
input.on(Input.EventType.TOUCH_START, this.onTouchStart, this);会监听不到。无论你点击哪里。
目前,我的解决方法是
在创建UI层级容器的时候,最上层,创建一个专门用于监听全局交互的层:
this._gameMain.interactionEventLayer = fgui.UIPackage.createObject(pakName,comName).asCom;
然后这个层专门监听交互事件:
this._gameMain.interactionEventLayer.node.on(Node.EventType.MOUSE_DOWN,this._gameMain.onMouseDown,this._gameMain);
这样暂时可以搞定我的业务需求,但似乎有点不雅。
没有找到相关结果
已邀请:
1 个回复
pandajc
赞同来自: