Sign in to follow this  

Sprite colliding with the Game Phaser

Recommended Posts


I'm currently in the middle of setting up the base of my game with the use of Phaser game engine but I'm having issue with the sprite colliding with the world bounds. 

I've used Tiling to create the backdrop and the ground etc. But I need help understanding how to define what the sprite should be colliding with. How do I collide with the ground, which is part of the whole tile.

Please see the attached 2 images, the sprite falls through the game as expected.,0, 400,300);

        console.log("in Game screen");
        //sprite width - 180px, height 247.5px
        map = this.add.tilemap('level');
        map.addTilesetImage('MyTile', 'tiles');
        layer = map.createLayer('Tile Layer 1');
        console.log("Json and sprite loaded");

        sprite = this.add.sprite(,, 'character');
        sprite.scale.setTo(0.2, 0.2);
        console.log("Character Loaded");
       this.physics.enable(sprite, Phaser.Physics.ARCADE);
       sprite.body.gravity.y  = 500;
       console.log("Physics added to sprite"); 

The above code is in the create function, I am using state management, as you can see I've added set world bounds, when adding this the sprite dissapears, I've tried numerous different dimension but I've still not come to a solution.


Any help would be much appreciated.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.