webdeveloper_issy Posted June 2, 2016 Share Posted June 2, 2016 Hi, I am currently developing a multiplayer web game. URL: bit.ly/1XTgB7 Now there are two things that get me crazy right now - map optimization. What I am currently trying: The map is 6400px by 6400px. To optimize it I think its good to cut the map in pieces of 100px by 100px and only show those pieces that are within the users viewport. I couldn't really work it out, I have done the cutting part but showing those within the viewport is what i fail at. Is it the right way to go? What other optimizations are possible? I currenly use .cacheAsBitmap = true. - Fall down bug When the player walks to the bottom of the map and shoots down every object other than the player 'falls'. What is the cause of this and how can I solve it? When I shoot left it does not do that Any help would be much appreciated Ps. Please keep the URL private Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 2, 2016 Share Posted June 2, 2016 any size between 256 or 1024 will be ok, i think. I use 256 in gameofbombs.com, and it works very well on 1920x1080. But there is the other way - https://github.com/pixijs/pixi-tilemap . Every time your viewport changes (to some point, like every 32px), just clear the tilemap and fill it again. Using this thing its not necessary to use RenderTextures or cacheAsBitmap. That plugin is not that effective on canvas2d, but for webgl. But be sure that all textures you use have the same BaseTexture: atlas thing, JSON HASH, create it with TexturePacker or Shoebox), otherwise there might be bugs with z-index. Quote Link to comment Share on other sites More sharing options...
webdeveloper_issy Posted June 2, 2016 Author Share Posted June 2, 2016 its just one huge image of 6400px by 6400px Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 2, 2016 Share Posted June 2, 2016 10 minutes ago, webdeveloper_issy said: its just one huge image of 6400px by 6400px Make a spritesheet/atlas of things, and construct a map from it. Dont forget that mobiles can have textures up to 4096. Also GPU will cull most of the image anyway if you draw that big map. If your map is very very very customized, then yes, just divide it to multiple textures of size 1024 or 2048 and it'll be just fine. Quote Link to comment Share on other sites More sharing options...
webdeveloper_issy Posted June 2, 2016 Author Share Posted June 2, 2016 25 minutes ago, ivan.popelyshev said: Dont forget that mobiles can have textures up to 4096. Also GPU will cull most of the image anyway if you draw that big map. Hmm that is something to think about, thanks 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.