@property (cc.Node)
startButton: cc.Node = null;
@property(cc.Node)
buttonHover: cc.Node = null;
onLoad () {
this.startButton.on(cc.Node.EventType.MOUSE_ENTER, this.enterBtn, this);
this.startButton.on(cc.Node.EventType.MOUSE_LEAVE, this.leaveBtn, this);
}
/**进入按钮范围*/
enterBtn() {
this.buttonHover.stopAllActions();
this.buttonHover.active = true;
cc.tween(this.buttonHover).parallel(
cc.tween().to(0, { scale: 1, opacity: 0 }).to(1, { scale: 1.5 }),
cc.tween().to(0.5, { opacity: 255 }).to(0.5, { opacity: 0 })
).union().repeatForever().start();
console.log("进入按钮范围")
}
/**离开按钮范围*/
leaveBtn() {
this.buttonHover.stopAllActions();
this.buttonHover.scale = 1;
this.buttonHover.opacity = 0;
this.buttonHover.active = false;
console.log("退出按钮范围")
}
When the mouse moves to the button range, there is a high probability that these two events will be triggered at the same time.
Is there something wrong with writing this way?