我正在尝试使用 Jvascript 制作游戏引擎。到目前为止,我有:
function gameEngine() {
this.canvas = $('canvas')[0];
this.ctx = this.canvas.getContext('2d');
this.framerate = 20;
this.resetCanvas = function() {
this.ctx.fillStyle = 'red';
this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
};
this.loop = function() {
this.resetCanvas();
};
this.run = function() {
setInterval(this.loop, this.framerate);
};
}
new gameEngine();
但是画布没有出现;为什么?