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

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

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...