JavaScript Splash屏幕settimeout问题



我一直在尝试在游戏启动时出现一个飞溅屏幕,并且确实会出现,但是它逐渐淡出。试图在功能中创建SettiMeut,但它停止工作并完全打破代码。

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,即:

function gameStart() {}
setTimeout(gameStart, 5000);

最新更新