Jump to content

Game crash when Physics are on


normanku
 Share

Recommended Posts

When I add "game.physics.startSystem(Phaser.Physics.ARCADE);", the game crash and all I see is a black image.

 var game = new Phaser.Game(600, 360, Phaser.CANVAS, '', { preload: preload, create: create, update: update });        var Keys = Phaser.Keyboard;        var speed = 2;        var cursors;         function preload () {            game.load.image('cielo', 'imagenes/fondos/background.png');            game.load.image('hierba','imagenes/fondos/hierba.png');            game.load.image('personaje','imagenes/sprites/personaje.png');        }        function create () {            game.world.setBounds(0, 0, 1000, 285+90);            //Fondos            cielo = game.add.tileSprite(-300,0,2000,285,'cielo');            hierba = game.add.tileSprite(-500,275,2000,90,'hierba');            pj = game.add.sprite(game.world.centerX, 150, 'personaje');            pj.anchor.setTo(0, 0);            game.physics.startSystem(Phaser.Physics.ARCADE);                        //game.physics.arcade.enable(pj);            //pj.body.collideWorldBounds = true;            cursors = game.input.keyboard.createCursorKeys();            game.camera.follow(pj);            game.camera.follow(pj, Phaser.Camera.FOLLOW_LOCKON);        }        function update() {            if (cursors.left.isDown)            {                pj.x -= speed;                hierba.x +=speed;                cielo.x +=(speed - (speed-1));            }            else if (cursors.right.isDown)            {                pj.x += speed;                hierba.x -=speed;                cielo.x -=(speed - (speed-1));            }            else            {                pj.angle = 0;            }        }

I don't know what's happening...

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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