Grazie compagno
Scherzi a parte grazie davvero perche' partendo dal tuo esempio ho ottenuto quello che volevo, ora l'ereditarieta` e l'overload funzionano insieme:
codice:
/* sprite class */
function SpriteBlank(){}
function Sprite (surname) {this.surname = surname;}
Sprite.prototype.getName = function (the)
{
console.log("(caller: sprite)");
alert(this.name + the + this.surname);
}
/* player class */
function Player (name,surname)
{
//Sprite.apply(this, arguments);
Sprite.call(this, surname);
this.name = name;
}
Player.constructor.prototype = Sprite;
SpriteBlank.prototype = Sprite.prototype;
Player.prototype = new SpriteBlank();
//Player.prototype = new Sprite("jack");
Player.prototype.getName = function (the)
{
console.log("(caller: player)");
this.constructor.prototype.getName.call(this,the);
}
var prova = new Player("jack", "ripper");
prova.getName(" the ");
Nonostante il risultato non ho comunque capito queste tre righe:
codice:
Player.constructor.prototype = Sprite;
SpriteBlank.prototype = Sprite.prototype;
Player.prototype = new SpriteBlank();
perche' devo passare per forza da un una classe vuota? se scrivo Player.prototype = new Sprite() non dovrebbe essere la stessa cosa?