kidos Posted August 10, 2014 Share Posted August 10, 2014 Hi guys, this forum is my last resort. I'm having a very bad performance on Android with Tilemap (checked with galaxy S2 and S3 )I'm using Phaser 2.0.5 and CocoonJS 2.0.2. If I'm doing it without tilemap, just a bunch of sprites the fps stays fixed on 60-62.But if I'm loading a tilemap with basic layers in it, I'm getting unstable fps (20-60), I'm not doing anything special, just an ordinary tilemap things.Tried to comment out everything, even just a basic code like: preload:// Load Tilemapthis.game.load.tilemap('mapData', 'assets/tilemaps/World1Level1.json', null, Phaser.Tilemap.TILED_JSON);this.game.load.image('mapImage', 'assets/tilemaps/World1Tileset.png');this.game.load.image('mapTrees', 'assets/tilemaps/World1Trees.png');create:// Adding a map and layerthis.map = this.game.add.tilemap('mapData');this.map.addTilesetImage('World1Tileset', 'mapImage');this.map.addTilesetImage('World1Trees', 'mapTrees');this.layerback1 = this.map.createLayer('Back1');this.layerback2 = this.map.createLayer('Back2');this.layermain = this.map.createLayer('Ground');this.layerledge = this.map.createLayer('Ledge');this.layerfront = this.map.createLayer('Foreground');// This resizes the game world to match the layer dimensionsthis.layermain.resizeWorld();// Some collisionsthis.map.setCollisionByExclusion([0],true, 'Ground');this.map.setCollision([2,3,4,5,6,7,22,23,24,25,26,27],true, 'Ledge');this.map.forEach(function(tile) {if ((tile.index >= 2 && tile.index <= 7) || (tile.index >= 22 && tile.index <= 27)) { tile.setCollision(false, false, true, false); // left, right, up, down}}, this, 0, 0, this.map.width, this.map.height, this.layerledge);update (didn't copied the whole player code):this.game.physics.arcade.collide(player.sprite, this.layermain);this.game.physics.arcade.collide(player.sprite, this.layerledge);If the player don't walk the fps stays at 60fps but once he's starting to walk and the tilemap needs to be rendered in a new position the fps gets unstable.Also tried to reduce the game resolution and all of my assets resolution which helped a bit but still not as I wanted.In iOS it works perfectly (checked with iPhone 4s and 5c) Has anyone experienced this problem before? Any ideas? Link to comment Share on other sites More sharing options...
lewster32 Posted August 10, 2014 Share Posted August 10, 2014 Many devices struggle with more than a few layers. This has been covered a few times before, most notably in my mind here: http://www.html5gamedevs.com/topic/6280-the-number-of-layers-created-in-tiled-is-responsible-for-poor-scrolling-performance-why/ Link to comment Share on other sites More sharing options...
kidos Posted August 10, 2014 Author Share Posted August 10, 2014 It seems like the maximum number for these devices are 4 layers only. More than that it freaks out !! THANKS! Link to comment Share on other sites More sharing options...
Recommended Posts