webdeveloper_issy Posted November 10, 2014 Share Posted November 10, 2014 I am creating an 2d tilegame with sometimes an huge map of tiles with different levels.Currently the game handles the tilemap(.json) as follow:- Download tilemap(.json). - loop through the map multidimensional array and addChild to displayObjectContainer each x,y have multiple layers so loop through x,y layers array and draw on the same x,y coordination. - When the viewport changes al the tiles that are not within the viewport are set to visable=false and the ones that are new in the viewport are set to visable=true. Is the performance influenced by child's that are set to visable=false?If so, what other techniques can I use to make an fast tilegame? Quote Link to comment Share on other sites More sharing options...
xerver Posted November 10, 2014 Share Posted November 10, 2014 Yes, but not as much as when it is visible. When updating the scene graph they still have to be checked if they are visible. You can also just remove them from the graph so they are not iterated at all. Quote Link to comment Share on other sites More sharing options...
webdeveloper_issy Posted November 10, 2014 Author Share Posted November 10, 2014 Oh that's not a good thing.Should I use an displayObjectContainer that will contain parts of the tilemap and hide it if not needed? Or let me ask it this way: What would be an good technique for drawing an tilemap on the viewport that will play nicely with pixijs? Quote Link to comment Share on other sites More sharing options...
xerver Posted November 10, 2014 Share Posted November 10, 2014 What I do is create each tile as a sprite, and set their positions to the proper locations. Then I calculate which need to be shown in the viewport and add those sprites to some rendered DOC. As the map pans I track the pan delta and when they have moved a tile length I remove all the sprite in the row/col they are panning away from and add in all the ones they are moving to. This way only the sprites actively shown in the viewport are rendered in the graph at all, it works really well. I did it in grapefruit's TileLayer Implementation and my phaser-tiled plugin's TileLayer Implementation. Grapefruit's implementation was a little different, it didn't create a sprite for each tile in the map. Rather it created one for each tile in the *viewport* and then just reused them from a pool while panning. That meant there was a lot less tile objects created, but also a lot less flexibility to edit the map. Quote Link to comment Share on other sites More sharing options...
webdeveloper_issy Posted November 10, 2014 Author Share Posted November 10, 2014 Thank you for your response and help!I will defenatly try to implement your principle.And have also found other topics on this forum that will help me.Keep up the good work! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.