参考代码:
this.btnOff.addEventListener("click", off.bind(this));
this.btnBomb.addEventListener("click", bomb.bind(this));
var _this = this;
var pb = null;
function off() {
if (pb == null) {
pb = new lib.sb1link();
pb.x = 600;
pb.y = 300;
pb.planeBombObj.bombObj.visible = false;
_this.addChild(pb);
pb.gotoAndPlay(1);
pb.planeBombObj.bombObj.addEventListener("bombover", over.bind(this));
pb.addEventListener("planeover", over.bind(this));
}
}
function over() {
console.log("ccss")
if (pb != null) {
pb.gotoAndPlay(0);
pb.planeBombObj.bombObj.removeEventListener("bombover",over.bind(this));
pb.removeEventListener("planeover",over.bind(this));
_this.removeChild(pb);
pb = null;
}
}
function bomb() {
pb.planeBombObj.bombObj.visible = true;
pb.planeBombObj.bombObj.gotoAndPlay(1);
}