Jump to content

Collision with a tilemap : blocked instead of touching ?


Recommended Posts

Hi everyone !




I am making a game for LD29 and I got some problems...


Here's the link of my game if you wanna try : https://dl.dropboxusercontent.com/u/84597005/LD29/index.html


Sometimes (randomly), the player doesn't collide with the map and goes through the map  :lol:

I tried to debug the player's body and I discovered something strange !

On this example when two sprites with an arcade type body collide, touching turns true. But on my game, touching never turns true whereas blocked turns true when the player hits something or walks.


Here's the code part about the player physics :

player = game.add.sprite(16 * 64, 13 * 64, 'pl');player.animations.add('walkr', [1, 2, 3, 2]);player.animations.add('walkl', [7, 8, 9, 8]);game.physics.enable(player, Phaser.Physics.ARCADE);player.body.collideWorldBounds = true;player.body.setSize(psize_x, psize_y, (64 - psize_x) / 2, 0);

About the map physics :

map = game.add.tilemap('ma');map.addTilesetImage('tset');map.setCollisionByExclusion([10]);layer = map.createLayer('A');game.physics.arcade.enable(layer);layer.resizeWorld();

And in the update function :

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

Here are my questions :

  • Did I do something wrong ?
  • Is the collision problem related to the touching/blocked problem ?


Thanks :D

Link to comment
Share on other sites

I think this may be an issue with your physics set up. Mainly your gravity settings because some people have been experiencing this issue because they set the gravity to really high values like 2000 etc.

What is your gravity value?

try reducing the gravity if it is a high value and that should sort things out a bit better

Link to comment
Share on other sites

Ah right yeah, I never use exclusion but use the between call because I use quite a few layers.

When I tested your game I fell through the map without any collision happening. He just fell straight to the floor.

You tried:

Player.body.debug = true;

Layer.debug = true;

Just for testing mainly so you could possibly better diagnose.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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