Jump to content

Can't collide laterally with objects


Recommended Posts

Hi, I've been hours trying to solve the problem but I can't. I hace three collisionable objects, the player, the floor and a box. The player and the box collide with the floor perfectly, but the player and the box only collide up and down. This is my code:


In create function:

function create () {            //Activate arcade physics            game.physics.startSystem(Phaser.Physics.ARCADE);             //Establish world limits            game.world.setBounds(129, 0, 1500, 285+90);            //Add elements and backgrounds            cielo = game.add.tileSprite(-300,0,3000,285,'cielo');            grass = game.add.tileSprite(-500,275,3000,90,'grass');            box = game.add.sprite(800,132,'box');            pj = game.add.sprite(game.world.centerX, 100, 'personaje');            pj.anchor.setTo(0, 0);            //Add Physics            game.physics.arcade.enable([pj,grass,box]);            game.physics.arcade.gravity.y = 500;                //Player physics                pj.body.collideWorldBounds = true;                pj.body.checkCollision.right = true;                pj.body.checkCollision.left = true;                //Grass physics                grass.body.allowGravity = false;                grass.body.immovable = true;                //Other elements physics                box.body.allowGravity = true;                box.body.inmovable = true;                box.body.checkCollision.right = true;                box.body.checkCollision.left = true;            //Keyboard recognising            cursors = game.input.keyboard.createCursorKeys();            jumpButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);            //Camera follow            game.camera.follow(pj, Phaser.Camera.FOLLOW_LOCKON);                   }        function update() {            game.physics.arcade.collide(pj,grass);            game.physics.arcade.collide(pj,box);            game.physics.arcade.collide(box,grass);...
Link to comment
Share on other sites


  • Recently Browsing   0 members

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