YTPo0OP Posted April 28, 2014 Share Posted April 28, 2014 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 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 Link to comment Share on other sites More sharing options...
Heppell08 Posted April 28, 2014 Share Posted April 28, 2014 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 More sharing options...
Heppell08 Posted April 28, 2014 Share Posted April 28, 2014 Also upon testing your game can i ask, is the brick tile you want to collide with the id of 10? If that is the only brick you want to collide with just set it as map.setCollision(10); Link to comment Share on other sites More sharing options...
YTPo0OP Posted April 28, 2014 Author Share Posted April 28, 2014 My gravity value is 1600 !map.setCollisionByExclusion([10]);sets all blocks except number 10 to collide Link to comment Share on other sites More sharing options...
Heppell08 Posted April 28, 2014 Share Posted April 28, 2014 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 More sharing options...
Recommended Posts