const {ccclass, property} = cc._decorator;
@ccclass
export default class LoadTest extends cc.Component {
@property(cc.Sprite)
spr:cc.Sprite = null
private remoteTex:cc.Texture2D = null
start () {
//监听一次事件
this.spr.node.once("mousedown",this.onMouseClick.bind(this))
//监听事件
this.spr.node.on("say",function(msg){
console.log(msg)
})
}
onMouseClick(event)
{
//发射事件
this.spr.node.emit("say","HelloWrold")
}
onDestroy()
{
//关闭监听事件
this.spr.node.off("say")
}
}