-1

一切正常,直到我放入这个 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);
}
4

1 回答 1

0

尝试:

Sun.draw(context); 也许你有错字

于 2013-11-07T16:52:57.130 回答