var enemy = {
x:30,
y:50,
size:50,
};
var enemys = [];
function Enemy(){
for(var i=0;i<10;i++){
enemys[i] = new Image();
enemys[i].src ='./img/enemy.png';
enemy.x += 10;
enemys[i].onload = function(){
context.drawImage(enemys[i], enemy.x, enemy.y, enemy.size, enemy.size);
};
}
};
这是想要的效果图!
你有什么问题?