我有一个画布可以绘制一个图像,但不会绘制同一文件类型的另一个图像。这是我的代码。
var context = document.getElementById('canv').getContext("2d");
var vx = 0;
var W = canv.width;
var H = canv.height;
var canvback = new Image();
canvback.src = "canvback.png";
var vx = 0;
var canvroad = new Image();
canvroad.src = "canvroad.png";
var car = new Image();
car.src = "mooncrash.png";
(function renderGame() {
window.requestAnimationFrame(renderGame);
context.clearRect(0, 0, W, H);
context.drawImage(canvback, 0, 0);
context.drawImage(canvroad, vx, 465);
context.drawImage(canvroad, canvroad.width-Math.abs(vx), 465);
if (Math.abs(vx) > canvroad.width) {
vx = 0;
}
vx -= 2;
context.drawImage(car, 500, 300);
}());
但是当我将mooncrash.png更改为car.png时,它不会绘制。有什么想法吗?