我上课“世界”和“墙”
function World() {
this.map = new Array();
this.createWorld = function(mapArray, ctx) {
console.log(mapArray.length);
for (var i = 0; i < mapArray.length; i++) {
obj = new Wall(mapArray[i, 0], mapArray[i, 1], mapArray[i, 2], mapArray[i, 3]);
//img = obj.createImg(ctx)
this.map.push(obj);
};
//return img;
}
this.getItem = function(i) {
return this.map[i];
}
this.getSize = function() {
return this.map.length;
}
}
function Wall(x, y, height, width) {
this.x = x;
this.y = y;
this.height = height;
this.width = width;
this.createImg = function(ctx) {
ctx.fillStyle = "rgb(166, 175, 179)";
ctx.fillRect(this.x, this.y, this.height, this.width);
return ctx.getImageData(0, 0, this.height, this.width);
}
//get
this.getX = function() {
return this.x;
}
this.getY = function() {
return this.y;
}
this.getHeight = function() {
return this.height;
}
this.getWidth = function() {
return this.width;
}
//set
this.setX = function(value) {
this.x = value;
}
this.setY = function(value) {
this.y = value;
}
}
当我在主程序中尝试获取Item Wall时,出现错误:Uncaught NotSupportedError:实现不支持所请求的对象或操作类型。 我的错误在哪里?