0
게임을 시작할 때 시작 화면이 나타나게하려고 시도했지만 표시되지만 너무 빨리 사라집니다. 함수 내에서 setTimeout을 만들려고했으나 작동을 멈추고 코드를 완전히 중단합니다.자바 스크립트 스플래시 화면 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 외부
당신은 아마 교체해야'gameStart();''에서는 setTimeout (gameStart, 5000)에 의해 setup''에서,'. – Xufox