Extending cc.Sprite

Extending cc.Sprite
0.0 0



I’d like to make a class that extends cc.Sprite. Right now, I’m trying to do it as follows:

var ExtendedSprite = cc.Sprite.extend(
    ctor:function () {

Then I have another class, “Ball,” meant to extend ExtendedSprite:

var Ball = ExtendedSprite.extend(

I’m then trying to create a new instance of Ball as follows:

this._ball = new Ball();

The app always crashes on the new Ball() line without giving me any further information. If I make Ball extend cc.Sprite, it works fine, so I’m clearly doing something wrong when I try to extend it with ExtendedSprite. Does anyone have any pointers for how to do this properly? Any advice is greatly appreciated!


Maybe it will help You. Ship.js from MoonWarrior game example:

var Ship = cc.Sprite.extend({
    ctor:function () {

        // needed for JS-Bindings compatibility
        cc.associateWithNative( this, cc.Sprite );

        //init life
        var shipTexture = cc.TextureCache.getInstance().addImage(s_ship01);
        this.initWithTexture(shipTexture, cc.rect(0, 0, 60, 38));

and next:

this._ship = new Ship();


Thanks for the response! Unfortunately, that’s not what I’m looking for; extending cc.Sprite once, like they do in that example, works fine. I’m trying to extend cc.Sprite with one class, and then extend that class.