The new extends throws RangeError
Old version (working with v3.10.5):
Kinetic.scaledImage = Kinetic.Image.extend({
init: function(config) {
this._super(config);
return this.setScale(scale);
}
});
New version (trying to make it work with v4.0.1):
Kinetic.scaledImage = function(config) {
return this._initImage(config);
};
Kinetic.scaledImage.prototype = {
_initImage: function(config) {
this.shapeType = 'scaledImage';
Kinetic.Image.call(this, config);
return this.setScale(scale);
}
};
Kinetic.Global.extend(Kinetic.scaledImage, Kinetic.Image);
Where it just throws a RangeError
Kinetic.Image.call(this, config);
// throws Uncaught RangeError: Maximum call stack size exceeded
I have quite a hierarchy for my canvas game, say:
Coin << Kinetic.droppableImage << Kinetic.scaledImage << Kinetic.Image
it's essential for me to get this to work.
I'll put together a tutorial that shows how to extend KineticJS objects and make sure that it's working as expected. stay tuned!
The problem of the suggested code is that the _initImage must be renamed to _initScaledImage (or similar). In the example you will have a recursive loop since the image constructor will call back on this._initImage.
+1 that's absolutely correct
Oh, I see. Thanks!