34 lines
827 B
TypeScript
Raw Permalink Normal View History

2025-04-24 17:03:28 +08:00
/**
*
* @author BrightLi
* @since 2020/5/3
*/
const {ccclass, property} = cc._decorator;
@ccclass
export default class SKMask extends cc.Component {
@property(cc.Boolean)
closeParent:boolean=false;
onLoad () {
this.node.on(cc.Node.EventType.TOUCH_START,(event:cc.Event)=>{
event.stopPropagation();
})
this.node.on(cc.Node.EventType.TOUCH_END,(event:cc.Event)=>{
event.stopPropagation();
if(this.closeParent && this.node.parent){
cc.tween(this.node.parent)
.to(0.3,{opacity:0})
.then(cc.callFunc(this.hide,this,this.node.parent)).start();
}
})
}
hide(node:cc.Node){
if(node && node.parent){
node.removeFromParent();
}
}
}