Hello,
i just switched to version 3.0pre2 and got this problem using jsb.
i derive a class from cc.Sprite. In the ctor i want to initialize it with a sprite frame like this:
var Ball = cc.Sprite.extend({
ctor:function(objScene, b) {
this._super();
// SpriteFrameCache
this._spriteFrameCache = cc.SpriteFrameCache.getInstance();
this.initWithSpriteFrame(this._spriteFrameCache.getSpriteFrame(b.sf));
....
in version 2.2 it worked as exptected but in version 3.0 i get the error TypeError: this.initWithTexture is not a function
does anybody know the reason for this?
thank you,
roelfsche
I created a new project as described: ./create_project.py -n test.standalone -k com.test.standalone -l javascript -p /path/to/project/cocos-x-3-test-standalone
And i just changed the delivered example code to the following:
var Ball = cc.Sprite.extend({
ctor : function() {
this._super();
cc.associateWithNative(this, cc.Sprite);
//'test' is not valid but just for testing, if method available
this.initWithSpriteFrame('test');
},
init: function() {
this._super();
}
});
var MyLayer = cc.Layer.extend({
sprite:null,
ctor:function() {
this._super();
cc.associateWithNative( this, cc.Layer );
},
init:function () {
this._super();
var myBall = new Ball();//cc.Sprite.createWithSpriteFrameName('test');
return true;
}
});
var MyScene = cc.Scene.extend({
ctor:function() {
this._super();
cc.associateWithNative( this, cc.Scene );
},
onEnter:function () {
this._super();
var layer = new MyLayer();
this.addChild(layer);
layer.init();
}
});
and i get the following error: iOS.app/src/myApp.js:32:TypeError: this.initWithSpriteFrame is not a function
Hi dumganhar,
thank you for your reply. is there a document that describes the api-changes? i searched the web but didn’t find this information.
and i just checked the js-api. there is no method setSpriteFrame on class cc.Sprite or parents. this would mean, the api isn’t cross-plattform between browser and ios anymore. is that right?