Raikoh Posted April 11, 2014 Share Posted April 11, 2014 Im using tilemap with P2 and it says to set the tiles that you want to collide with (map.setCollisionBetween()) but even without this line all my tiles collide. I tried to set the collides parameter to false and the tiles still collides. In the P2 physique example "tilemap gravity" if i delete the line map.setCollisionBetween(1, 12) it doesn't change anything. ConvertTilemap is supposed to work only on the tiles that we define with map.setCollision, but it uses all the tiles on the layer. Is it a bug, or i don't get it? rpiller 1 Link to comment Share on other sites More sharing options...
hellochar Posted April 14, 2014 Share Posted April 14, 2014 I'm pretty sure this is a bug in the engine. In the source for p2.convertTilemap, a collision body is only *ignored* for a tile if the tile doesn't actually exist (aka the index is 0), regardless of if setCollisionBetween is set on it or not. To fix, go to line 69015 of phaser.js; you should see if (tile)change that to if (tile && tile.collides) Link to comment Share on other sites More sharing options...
rich Posted April 14, 2014 Share Posted April 14, 2014 Yes well spotted, this is now fixed in the dev branch. m4d3 1 Link to comment Share on other sites More sharing options...
m4d3 Posted April 15, 2014 Share Posted April 15, 2014 I'm using a updated dev build (build with grunt) and my tilemap still disappears after the first p2 physics collision. I have a seperate collision mesh for the ground and the tilemap is just for visual represantation so i dont wont it to collide with anything and just stay in place. Doesnt work for me so far no matter what im trying. Link to comment Share on other sites More sharing options...
m4d3 Posted April 15, 2014 Share Posted April 15, 2014 mh, the problem doesn't seem to be the physics. the tilemap just disappears when the camera is moved (it's a FOLLOW_TOPDOWN cam). Link to comment Share on other sites More sharing options...
rpiller Posted April 15, 2014 Share Posted April 15, 2014 I noticed this same issue and my character would just start moving on startup (guessing bodies inside bodies causing it to just go whacky). Are you using game.camera.follow(player); for camera follow? I use this and it works great. Link to comment Share on other sites More sharing options...
m4d3 Posted April 15, 2014 Share Posted April 15, 2014 yes, the camera follow works, i tried disabling everything and moved the camera with the cursors like in this example, and the tilemap still disappears, when im not moving the camera everything is fine. http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=csv+map.js&t=csv%20map Im using a Tilemap JSON File generated by Tiled btw. Simple code:var map = this.game.add.tilemap('level1');map.addTilesetImage('Level_1', 'tiles'); var layer = map.createLayer('Layer1');layer.resizeWorld(); Link to comment Share on other sites More sharing options...
rpiller Posted April 15, 2014 Share Posted April 15, 2014 I'm doing the exact same thing as you. Using Tiled and exporting to JSON. function preload() { game.load.tilemap('map', 'content/maps/Test01.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('tileset1', 'content/images/tileset.png', 32, 32); game.load.spritesheet('player', 'content/images/test.png', 24, 32, 12);}function create() { game.physics.startSystem(Phaser.Physics.P2JS); // create map map = game.add.tilemap('map'); map.addTilesetImage('tileset1'); layer1 = map.createLayer('Ground'); layer1.resizeWorld(); layer2 = map.createLayer('Object'); layer2.resizeWorld(); layer3 = map.createLayer('Foreground'); layer3.resizeWorld();} Link to comment Share on other sites More sharing options...
m4d3 Posted April 15, 2014 Share Posted April 15, 2014 i cant seem to fix this. btw. you dont have to call resizeWorld() for each of your layers if your map stays the same size. Link to comment Share on other sites More sharing options...
Raikoh Posted April 15, 2014 Author Share Posted April 15, 2014 m4d3 are you using chrome canary, if yes try chrome. Link to comment Share on other sites More sharing options...
Recommended Posts