HI 同仁们:
我使用的是cocos2dx js 3.0 rc3 现在实现一个自动记步的特效 就是从1 数到 100 在JSB环境中出现
TypeError: cc.ActionInterval.prototype.ctor is undefined
```
H5环境下没问题 我该怎么解决它呢? 同时 我在继承 cc.Event.extend 的时候 也会有类似的问题
是否是继承的时候还是需要写JSB? 如果是 该怎么操作 或者 有什么捷径 不通过继承 通过其他方式实现类似效果?
下面是我的实现代码 会在JSB环境下报错 web环境正常 谢谢大家了
var HelloWorldLayer = cc.Layer.extend({
ctor:function () {
this._super();
var label = cc.LabelTTF.create("0","Arial",20);
label.setPosition(cc.p(cc.winSize.width/2,cc.winSize.height/2));
var count = cc.countBMTextNumber(0,100,1);
var action = cc.spawn(cc.fadeIn(.6).easing(cc.easeBounceOut()));
label.runAction(cc.sequence(cc.delayTime(.4),action,count));
this.addChild(label);
return true;
}
});
var HelloWorldScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layer = new HelloWorldLayer();
this.addChild(layer);
}
});
var CountBMTextNumber = cc.ActionInterval.extend({
_from:0,
_to:0,
_duration:0,
_accTime:0,
_label:null,
_postStr:null,
ctor: function (f, t, d, post) {
cc.ActionInterval.prototype.ctor.call(this);
this._from = f;
this._to = t;
this._duration = d;
this._postStr = post;
cc.ActionInterval.prototype.initWithDuration.call(this, d);
},
/**
* Start the action with target.
* @param {cc.Label} target
*/
startWithTarget:function (target) {
cc.ActionInterval.prototype.startWithTarget.call(this, target);
this._label = target;
this._label.retain();
},
/**
*
* @param {Number} dt
*/
update:function (dt) {
var number = this._from + (this._to - this._from) * dt;
number = number.toFixed(0);
if(this._label && this._label.setString){
var text = number + this._postStr;
this._label.setString(text);
}
}
});
cc.countBMTextNumber = function (f, t, d, post) {
if(arguments.length<4){
post = "";
}
return new CountBMTextNumber(f, t, d, post);
};
```