我用的是Cocos Creator 1.4.2版本,用你的代码试了一下,最终是显示出来的。
================================================
因为你这边没有显示出来,并且我也不知道你这边是什么情况,所以提供两种解决办法:
1.办法1:计算好要闪烁的时间,比如这里是3秒,但是你是2秒闪烁5次,那么三秒就是闪烁7.5次,想下取整是7次,所以代码可以写成
let blinksAction = cc.blink(3, 7);
this.button.node.runAction(blinksAction);
2.办法2:通过查看cc.blink的源码可以发现,blink操作的其实是节点的opacity,所以在stopAction的时候加上一句
this.button.node.opacity = 255;
附:cc.blink的源码:
cc.Blink = cc.ActionInterval.extend({
_times: 0,
_originalState: false,
ctor: function(duration, blinks) {
cc.ActionInterval.prototype.ctor.call(this);
void 0 !== blinks && this.initWithDuration(duration, blinks);
},
initWithDuration: function(duration, blinks) {
if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
this._times = blinks;
return true;
}
return false;
},
clone: function() {
var action = new cc.Blink();
this._cloneDecoration(action);
action.initWithDuration(this._duration, this._times);
return action;
},
update: function(dt) {
dt = this._computeEaseTime(dt);
if (this.target && !this.isDone()) {
var slice = 1 / this._times;
var m = dt % slice;
this.target.opacity = m > slice / 2 ? 255 : 0;
}
},
startWithTarget: function(target) {
cc.ActionInterval.prototype.startWithTarget.call(this, target);
this._originalState = target.opacity;
},
stop: function() {
this.target.opacity = this._originalState;
cc.ActionInterval.prototype.stop.call(this);
},
reverse: function() {
var action = new cc.Blink(this._duration, this._times);
this._cloneDecoration(action);
this._reverseEaseList(action);
return action;
}
});
cc.blink = function(duration, blinks) {
return new cc.Blink(duration, blinks);
};