Jump to content

Tilemap coliding on wrong side


jgcbrouns
 Share

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)

 

Quote

       var data = '';

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

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

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


        console.log(data);

        //  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;

        console.log(this.layer);
        this.layer.debug = true;
        this.game.physics.startSystem(Phaser.Physics.ARCADE);

 

and in the update function:

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

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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