Seanw265 Posted April 25, 2014 Share Posted April 25, 2014 Hello all,I'm new to HTML5 and JS game programming. I come from an Obj-c/cocos2d background. I've been struggling to get the Arcade physics to recognize the scaling of a Tilemap layer.The layer is created as follows:this.map = this.game.add.tilemap('level');this.map.addTilesetImage('tileset','tiles');this.map.setCollisionBetween(44, 50);this.layer = this.map.createLayer('Tile Layer 1');this.layer.scale.x = 2;this.layer.scale.y = 2;this.layer.debug = true;this.layer.fixedToCamera = false;The layer displays perfectly fine(along with the debug drawing), but the collisions do not scale at all. I have tried altering the collisionWidth and collisionHeight of the TilemapLayer and it doesn't seem to have the desired effect. I am checking for collisions in an update method by this function:game.physics.arcade.collide(sprite,layer);This was posted in regard to Phaser 1.1: You can now also scale the layers and the collision system recognises this and uses the new scaled size for all collision. I should point out that I am running Phaser 2.0.4 Any help is greatly appreciated! Link to comment Share on other sites More sharing options...
villetou Posted May 10, 2014 Share Posted May 10, 2014 Have you tried setting the scale first, before the .setCollisionBetween call? Also, calling this.layer.resizeWorld() after setting scaling might help with these kind of problems. Link to comment Share on other sites More sharing options...
Doodlemeat Posted May 11, 2014 Share Posted May 11, 2014 @villetou There is no way to do this. We have to wait until it become supported. Link to comment Share on other sites More sharing options...
villetou Posted May 19, 2014 Share Posted May 19, 2014 @Doodlemeat you're probably right. There was another forum post where the conclusion was the same. The tilemap scaling doesn't work well with the physics systems (or atleast arcade). You could also try a more indirect approach and reduce the game resolution to half and then scale other objects of the game to 0.5, so that the tilemap appears twice the size. Then you can let the game resize itself to bigger size and get almost the same end result. Of course it won't be exactly the same (gameplay won't be as smooth), but should work for the time being. Remember to set antialiasing off if you're using pixel art Link to comment Share on other sites More sharing options...
Larzan Posted May 9, 2015 Share Posted May 9, 2015 As of 2.3 you can use the new setScale method to scale a Layer while automatically adapting the collision boundries.More detail here: GitHub Link to comment Share on other sites More sharing options...
Recommended Posts