我现在在 UI 层添加了一个 全屏的触摸层,对触摸层进行多点触摸的监听,遍历所有触摸点,判断是否点击到了某按钮,暂时性的解决了这个问题
onTouchBegan(event: cc.Event.EventTouch) {
let touches = event.getTouches();
for (let i = 0; i < touches.length; i++) {
const touch = touches[i];
if(this.isTouched(this.leftBtnPanel,touch) && this.icoLeft.active){
}else if(this.isTouched(this.rightBtnPanel,touch) && this.icoRight.active){
}else if(this.isTouched(this.btnJump,touch)){
}else if(this.isTouched(this.btnSkill,touch)){
}
}
}
onTouchMoved(event: cc.Event.EventTouch) {
let touches = event.getTouches();
for (let i = 0; i < touches.length; i++) {
const touch = touches[i];
if(this.isTouched(this.leftBtnPanel,touch) && this.icoLeft.active){
}else if(this.isTouched(this.rightBtnPanel,touch) && this.icoRight.active){
}
}
}
onTouchEnded(event: cc.Event.EventTouch) {
this.onTouchCancel(event);
}
onTouchCancel(event: cc.Event.EventTouch) {
let touches = event.getTouches();
for (let i = 0; i < touches.length; i++) {
const touch = touches[i];
if(this.isTouched(this.leftBtnPanel,touch) && this.icoLeft.active){
}else if(this.isTouched(this.rightBtnPanel,touch) && this.icoRight.active){
}else if(this.isTouched(this.btnJump,touch)){
}else if(this.isTouched(this.btnSkill,touch)){
}
}
}