Jump to content

Tilemap coliding on wrong side


Recommended Posts

Hi all

I am creating a maze-game where I am placing walls by means of a tilemap. However the collision of the ball with these tiles seem to be on the wrong side of the wall? In other words: If the ball approaches from the left-side, it collides with the wall on the right side!

In the video the problem can be seen. 

What I want is that the ball collides with the side of the wall that it collides with first, like any game!

Thanks in advance for your help :)

( I am using Phaser 2.2)



       var data = '';

        for (var y = 0; y < 33; y++)
            for (var x = 0; x < 33; x++)
                if(y>5 && y<20 && x ==3){
                data += 1;

                if (x < 32)
                    data += ',';

            if (y < 32)
                data += "\n";


        //  Add data to the cache
        this.game.cache.addTilemap('dynamicMap', null, data, Phaser.Tilemap.CSV);

        //  Create our map (the 16x16 is the tile size)
        map = this.game.add.tilemap('dynamicMap', 50, 50);

        bgcolor = this.game._MAINCOLOR;

        map.addTilesetImage('wallblock', 'wallblock');

        //  0 is important
        this.layer = map.createLayer(0);

        map.setCollisionBetween(1, 50, true);
        //  Scroll it
        // layer.resizeWorld();

        this.layer.wrap = false;

        this.layer.debug = true;


and in the update function:

this.physics.arcade.collide(this.layer, this.player);

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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