Jump to content

Arcade Physics Black Screen


phasedev
 Share

Recommended Posts

Hi :)

 

So I am brand new to Phaser, I have been playing around with it for a few days, so I apologize if this is a really dumb question, but I have been following this tutorial from Photon Storm (http://www.photonstorm.com/phaser/tutorial-making-your-first-phaser-game), and when I add the Arcade Physics to the file all I get is a black screen. I have copied and pasted all of the code to make sure I don't have any typos but I still get a black screen.

 

Could someone please answer why this is, and how I could fix it. 

 

Thank you.

 

This is the code.

<!doctype html><html>    <head>        <meta charset="UTF-8" />        <title>hello phaser!</title>        <script src="phaser.min.js"></script>    </head>    <body>    <script type="text/javascript">    window.onload = function() {        var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });        function preload () {            game.load.image('sky', 'assets/sky.png');            game.load.image('ground', 'assets/platform.png');            game.load.image('star', 'assets/star.png');            game.load.spritesheet('dude', 'assets/dude.png', 32, 48);        }        var platforms;        function create() {                        game.physics.startSystem(Phaser.Physics.ARCADE);                    game.add.sprite(0, 0, 'sky');            platforms = game.add.group();            //  We will enable physics for any object that is created in this group            platforms.enableBody = true;                    // Here we create the ground.            var ground = platforms.create(0, game.world.height - 64, 'ground');                    //  Scale it to fit the width of the game (the original sprite is 400x32 in size)            ground.scale.setTo(2, 2);                    //  This stops it from falling away when you jump on it            ground.body.immovable = true;                    //  Now let's create two ledges            var ledge = platforms.create(400, 400, 'ground');                    ledge.body.immovable = true;                    ledge = platforms.create(-150, 250, 'ground');                    ledge.body.immovable = true;                                                 // The player and its settings            player = game.add.sprite(32, game.world.height - 150, 'dude');                    //  We need to enable physics on the player            game.physics.arcade.enable(player);                    //  Player physics properties. Give the little guy a slight bounce.            player.body.bounce.y = 0.2;            player.body.gravity.y = 300;            player.body.collideWorldBounds = true;                    //  Our two animations, walking left and right.            player.animations.add('left', [0, 1, 2, 3], 10, true);            player.animations.add('right', [5, 6, 7, 8], 10, true);                            player.body.gravity.y = 300;        }        function update() {        }    };    </script>    </body></html>

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...