Seanw265 Posted April 24, 2014 Share Posted April 24, 2014 I can successfully scale the graphical representation of the tile map however, using arcade physics, the collision locations do not change. Any help is greatly appreciated. I am using Phaser 2.0.4 Link to comment Share on other sites More sharing options...
Zielak Posted July 11, 2014 Share Posted July 11, 2014 Yeah, I would like an answer for that too. Phaser 2.0.5 Link to comment Share on other sites More sharing options...
ianmcgregor Posted July 11, 2014 Share Posted July 11, 2014 We had this code for scaling tilemaps in a recent game using Phaser 2.04 and it did work with Arcade physics. Map.prototype.scaleTilemapData = function(name, scale) { var tilemapData = this.game.cache.getTilemapData(name); if(tilemapData.isScaled) { return; } this.scaleTileWidthAndHeight(tilemapData, scale); this.scaleTilesets(tilemapData, scale); this.scaleObjectLayers(tilemapData, scale); tilemapData.isScaled = true;};Map.prototype.scaleTileWidthAndHeight = function(tilemapData, scale) { tilemapData.data.tilewidth *= scale; tilemapData.data.tileheight *= scale;};Map.prototype.scaleTilesets = function(tilemapData, scale) { var tilesets = tilemapData.data.tilesets, l = tilesets.length, tileset; for(var i = 0; i < l; i++) { tileset = tilesets[i]; tileset.imageheight *= scale; tileset.imagewidth *= scale; tileset.tileheight *= scale; tileset.tilewidth *= scale; }};Map.prototype.scaleObjectLayers = function(tilemapData, scale) { var layers = tilemapData.data.layers, l = layers.length, layer; for(var i = 0; i < l; i++) { layer = layers[i]; if(Object.prototype.toString.call(layer.objects) === '[object Array]') { layer.objects = this.scaleObjects(layer.objects, scale); } }};Map.prototype.scaleObjects = function(objects, scale) { var l = objects.length, object; for(var i = 0; i < l; i++) { object = objects[i]; object.x *= scale; object.y *= scale; } return objects;}; Zielak 1 Link to comment Share on other sites More sharing options...
Recommended Posts