一切正常,直到我放入这个 for 循环,然后我得到错误 sun is not defined。
Sun.prototype.TriangleOne = function(pContext) {
for (var i = 0, i < 12; i++) {
pContext.save();
pContext.translate(this.getX() - 80, this.getY());
pContext.rotate(Math.PI / 2);
this.Triangle(pContext);
pContext.restore();
}
}
function draw() {
context.translate(canvas.width / 2, canvas.height / 2);
for (var i = 0; i < houses.length; i += 1) {
houses[i].draw(context);
}
sun.draw(context);
}