2017-03-15 5 views

答えて

1

あなたif文の複数の各ループを実行することができますので。 x == 500の場合は、> 0です。

gameLoop()機能を大幅に簡略化することができます。

function gameLoop() { 

    renderer.render(stage); 
    cat.x = cat.x + moveX; 

    if (cat.x <= 0 || cat.x >= 500) { 
     moveX = -moveX; 
    } 

    requestAnimationFrame(gameLoop); 
} 

http://jsfiddle.net/74j0u5zf/5/

関連する問題