2016-12-13 13 views
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); 
} 

助けてください。

ありがとうございます。

+0

あなたはおそらく 'gameStartを()を交換する必要があります;'; 'に' 'のsetTimeout(gameStart、5000)によってsetup'。 – Xufox

答えて

0

移動のsetTimeout関数gameStart、すなわち外:

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

これは 'setup()'にあるはずです。 – Barmar

関連する問題