toto88x Posted August 10, 2014 Share Posted August 10, 2014 Hello, I'm making a 2D platformer game with Tiled and Phaser with Arcade physics. I'd like to change the body size of some of my tiles. For example: reduce by 2 the collision area of the spikes in my game.How can I do that? Thanks! Link to comment Share on other sites More sharing options...
lewster32 Posted August 10, 2014 Share Posted August 10, 2014 I'm no expert on Tilemaps but I believe the point of them is that all of the tiles are uniformly sized, and the collision code expects that. You may have to convert your spikes to Sprites and then you can alter the size as needed. Link to comment Share on other sites More sharing options...
ssshenkie Posted August 10, 2014 Share Posted August 10, 2014 Make sure the tiles you are trying to scale are inside an object layer, that is very important. Then in your code just load the necessary json file and tiles image, and write down this:map = game.add.tilemap('map');map.addTilesetImage('tiles');// create our enemies groupenemies = game.add.group();enemies.enableBody = true;// And now we convert all of the Tiled objects with an ID of 5 into sprites within the enemies groupmap.createFromObjects('enemies', 5, 'enemy',0, true, false, enemies);// Loop trough all enemies and scale to the size we wantenemies.forEach(function(enemy){ enemy.scale.x = 1.5; enemy.scale.y = 1.5;});createFromObjects() Here is a working example:http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=create+from+objects.js&t=create%20from%20objects And the json file they use in the example (you can search for ID number inside here):http://examples.phaser.io/assets/tilemaps/maps/features_test.json Link to comment Share on other sites More sharing options...
Recommended Posts