parkm / oldbpm

A JavaScript game where you shoot at bubbles.
0 stars 1 forks source link

createClass won't work with another level of inheritance. #23

Closed parkm closed 10 years ago

parkm commented 10 years ago

I was trying to create an object structure like:

But I was running into stack overflows. this._super in GameObject was returning GameObject.prototype I believe. So doing this caused a loop:

init: function() {
    this._super.init.call(this);
}
dgpt commented 10 years ago

Ah, I know what the problem is. So the Bubble calls this._super.init.call(this) Which translates to GameObject.prototype.init.call([Object bubble]) Then GameObject calls this._super.init.call(this) using the bubble instance as its this, which causes a recursion loop. I'm looking into fixing it now.

dgpt commented 10 years ago

Eh, this is getting too complex. We'll just have to call the super methods on the prototype the old fashioned way.

BasicObject.init.call(this) etc.