想实现一个用户X分钟没点击屏幕任何位置,就进行休眠状态。有没有简便的实现方法?我能想到的就是修改引擎底层,在触摸时间的总入口哪里处理。有触摸就吧计时器清理。
/**
-
自定义组件-让节点触摸时间向下穿透
*/
cc.Class({
extends: cc.Component,properties: {
clickEvents: Array,
},onLoad() {
this.clickEvents= new Array();
this.node.on(cc.Node.EventType.TOUCH_START, (event) => {
if (this.clickEvents == null) {
return;
}
cc.Component.EventHandler.emitEvents(this.clickEvents, event);
});
this.node._touchListener.setSwallowTouches(false);
}
});
1赞
cc.Component.EventHandler.emitEvents(this.clickEvents, event);这句话是干嘛的,好像没什么用啊
this.node._touchListener.setSwallowTouches(false);
想知道一下touchiListener这个属性是在哪里定义的,我找了一下没有找到