屏蔽父类点击事件
在父容器上添加sprite_1
,在sprite_1
上添加子对象sprite_2
,分别添加点击事件
代码如下:
let sprite_1: egret.Sprite = new egret.Sprite();
sprite_1.touchEnabled = true;
sprite_1.name = "sprite_1"
sprite_1.graphics.beginFill(0x000);
sprite_1.graphics.drawRect(0, 0, 300, 300);
sprite_1.graphics.endFill();
this.addChild(sprite_1);
let sprite_2: egret.Sprite = new egret.Sprite();
sprite_2.touchEnabled = true;
sprite_2.name = "sprite_2"
sprite_2.graphics.beginFill(0xffffff);
sprite_2.graphics.drawRect(0, 0, 100, 100);
sprite_2.graphics.endFill();
sprite_1.addChild(sprite_2);
sprite_1.addEventListener(egret.TouchEvent.TOUCH_TAP, (e: egret.TouchEvent)=> {
console.l