talamask Posted September 14, 2018 Share Posted September 14, 2018 (edited) Here's my create() function. create() { const map = this.make.tilemap({key: "level_map"}); const tileset = map.addTilesetImage("Caves", "tiles"); const walls = map.createStaticLayer("walls", tileset, 0, 0); const decals = map.createStaticLayer("decals", tileset, 0, 0); // create player sprite this.player = this.physics.add.sprite(16*9, 16*23, "player"); // set collitions tiles by property walls.setCollisionByProperty({collides: true}); // show collision tiles with different color const debugGraphics = this.add.graphics().setAlpha(0.45); walls.renderDebug(debugGraphics, { tileColor: new Phaser.Display.Color(40, 255, 48, 255), // Color of non-colliding tiles collidingTileColor: new Phaser.Display.Color(243, 134, 48, 255), // Color of colliding tiles faceColor: new Phaser.Display.Color(40, 39, 37, 255) // Color of colliding face edges }); // setup physics this.physics.add.collider(this.player, walls); // cursors this.cursors = this.input.keyboard.createCursorKeys(); // camera this.camera = this.cameras.main; this.camera.startFollow(this.player); this.camera.setBounds(0, 0, map.widthInPixels, map.heightInPixels); } I load up a tilemap, read layers "walls" and "decals", set a collision by property and then add a collider of player to "walls". For me it seems that everything is ok. In Tiled I set up a "collides" bool variable and marked all impassible tiles as true, saved a level, exported JSON.. For debugging properties I even set up "walls.renderDebug" thing. And of course after I launch the game I get a screen filled with green areas and my player falling down through a level. One small note is that if I, instead of setCollisionByProperty use setCollisionBetween(1, 100) for example I do get some areas colored orange. So, what am I doing wring in my code? In attachement there is my JSON file, maybe something is wrong with it. level_02b64.json Edited September 14, 2018 by talamask added JSON with level Link to comment Share on other sites More sharing options...
maikthomas Posted October 21, 2018 Share Posted October 21, 2018 I seem to have the same issue. I can see the properties in the json but they are not read by phaser. Link to comment Share on other sites More sharing options...
Jursdotme Posted December 1, 2018 Share Posted December 1, 2018 Im am having the same problem. Did you find a solution? Link to comment Share on other sites More sharing options...
talamask Posted December 3, 2018 Author Share Posted December 3, 2018 Actually the problem was that I was using Tiled version that was not fully supported by Phaser. Mine was too new, so to say, but when I installed some older version problem disappeared. pankucsi 1 Link to comment Share on other sites More sharing options...
Recommended Posts