0
我一直在尝试使游戏开始时出现闪屏,并且它确实出现,但它会以太快的速度淡出。试图在函数内创建setTimeout,但它停止工作并完全破坏代码。JavaScript启动画面setTimeout问题。
var introimg;
var intro = true;
function gameStart() {
ctx.clearRect(0,0,window.innerWidth, window.innerHeight);
ctx.drawImage(introimg, 0,0,window.innerWidth, window.innerHeight);
//setTimeout(gameStart, 5000);
}
function setup(){
introimg = new Image();
introimg.src = 'ICE/data/splash.png';
document.addEventListener("touchstart", onTouchStart);
document.addEventListener("touchmove", onTouchMove);
document.addEventListener("touchend", onTouchEnd);
gameStart();
draw();
}
function draw(){
ctx.fillStyle = "rgba(0,0,0,0.1)";
ctx.fillRect(0,0,window.innerWidth,window.innerHeight);
for(var i = 0;i<ressources.length;i++){
ressources[i].display();
}
requestAnimationFrame(draw);
}
请帮忙。
预先感谢您。
你可能需要更换'gameStart();''在用'的setTimeout(gameStart,5000)setup';'。 – Xufox