gameclosure uses the class structure for code modulation
example code 1:
exports = Class(GC.Application, function() {
//Code here
});
I was trying to look for the code inside the Class varible,
I found a Class varible declartion in jsio/packages/base.js
exports.Class = function(name, parent, proto) {
return exports.__class__(
function() {
return this.init && this.init.apply(this, arguments);
},
name, parent, proto);
}
but, this function is not syntactically the same as to be used by the example code mentioned above. so, my question is where is the class varibale located. and what is the use for the jsio/packages/base.js class variable? also, how can i call the super class methods from the extended class?
I Think you have all ready found the answer,incase you havent found the answer to the second question. this is how you can call a super class method from the base class.
var Vehicle = Class(function () {
this.init = function (wheels) {
this.wheels = wheels;
};
});
var Truck = Class(Vehicle, function (supr) {
this.init = function (hp, wheels) {
supr(this, "init", [wheels]);
this.horsepower = hp;
};
this.printInfo = function () {
$('#result').html('I am a truck and I have ' + this.wheels +
' wheels and ' + this.horsepower + ' hp.');
};
});
var t = new Truck(350, 4);
t.printInfo();