阶段 - 我的图像不加载

Phase - My images dont load

我是移相器的新手。我开始看 youtube 系列,我首先 它的问题。 我的背景图片不加载。 我有这个js代码

/* global Phaser */

var game = new Phaser.Game(1200,600, Phaser.AUTO);

var GameState = {
    preload : function(){
        this.load.image('background','assets/images/background.png');
    },
    create: function() {
        this.background = this.game.add.sprite(0, 0, 'background');
    },
    update : function() {

    }
};

game.state.add('GameState',GameState);

我的index.php代码:

<!DOCTYPE html>
<html lang='cs' dir='ltr'>
    <head>
        <meta charset='UTF-8'>
        <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale-1, user-scalable=no'/>

        <title>8. úkol</title>
    </head>
    <body>
        <section>
        <script type='text/javascript' src='js/phaser.js'></script>
        <script type='text/javascript' src='js/main.js'>

        </script>
        </section>
    </body>
</html>

我的背景图片大小为 600x135

我把它添加到代码中解决了

game.state.start('GameState');

//您好,只需复制所有这些,它现在应该可以解决您的问题 Phaser 它是一个非常有趣的框架,请随时给我发送任何问题的直接消息,我对此很陌生,我会更多很高兴向你展示我所知道的一切,祝你有美好的一天!

   /* global Phaser */



var GameState = {
preload : function(){
    this.load.image('background','assets/images/background.png');
},
create: function() {
    this.background = this.game.add.sprite(0, 0, 'background');
},
update : function() {

}
};

var game = new Phaser.Game(1200,600, Phaser.AUTO);  //<--- use it down
                                                   //    here its neater
game.state.add('GameState',GameState);
game.state.start('GameState')