誰でも私が間違っていることを教えてもらえますか? HERESにコードを継承はJSでは機能しませんか?
this.parent.Thing is not a function
this.parent.Thing(x,y);
:
このエラーを取得します。
[Break On This Error] this.parent.Thing(x,y);
//Thing class start
function Thing(x, y){
this.x = x;
this.y = y;
}
Thing.prototype.setX = function(newX){
this.x = newX;
}
Thing.prototype.setY = function(newY){
this.y = newY;
}
Thing.prototype.getX = function(){
return this.x;
}
Thing.prototype.getY = function(){
return this.y;
}
//Thing class end
//player start
Player.prototype = new Thing();
Player.prototype.constructor=Player; // Otherwise instances of Cat would have a constructor of Mammal
Player.prototype.parent = Thing.prototype;
function Player(x, y){
this.parent.Thing(x,y);
}
//player end
var player = new Player(100,100);
はここからそれを得た:http://phrogz.net/js/classes/OOPinJS2.html – CyanPrime
問題は何? – Pointy
問題を追加しました。 – CyanPrime