Archived

This topic is now archived and is closed to further replies.

Tiled layer so slow?

This topic is 5000 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I''m using MIDP 2.0 to create my game. I have made a tiled layer using three kinds of 15x15 cells. My tiled layer size is 30x30 cells. When I test this with my controllable sprite, using Nokia emulator all runs well and smooth. But when I use WTK emulator or Ericsson Z1010, it runs incredibly slow. I tried to profile my code, and found out that the tiled layer drawing consumed 90% of the cycles. I tried to make my cell bigger, 30x30, and I changed my tiled layer size into 10x10 cells. That means my whole world will have 300x300 pixels size. I test it using Ericsson Z1010 emulator, now it runs well. If using quite big tiled layer gives so slow performance, how can we make a huge world to explore? Thanks a lot.

Share this post


Link to post
Share on other sites
The same thing has been discussed on the J2MEGamer forums (http://www.j2megamer.com/).

The problem is that the TiledLayer does not know the viewport and it thus draws the ENTIRE tilemap at once. This is a huge performance loss and noone really knows what Sun was thinking when they devised this class.

In my game I solved it by sectors. I found an acceptable tilemap size (for me it is 60 * 40 with 16*16 tiles) and then I just created sectors. So every level in my game consists out of four different 60*40 maps which shift as soon as the player reaches a "checkpoint" or whatever you''d like to call it. In my game, it''s rooms.

There is no other apparent solution to this (while using TiledLayer) I''m afraid.

Sun has gotten several remarks on this and hopefully it will be fixed in a new revision.

Share this post


Link to post
Share on other sites
Heh. I already have written a fair amount of MIDP 1.0 code to handle tiled maps (all very much *not* publically available, sorry business is business after all), thanks for the warning - I''ll have to look at this again when I start writing stuff for 2.0.

Share this post


Link to post
Share on other sites
Thanks for the replies.

I see then, so I should handle tiled layer using MIDP 1.0 way. (i.e should determine which area is currently visible on the viewport and draw that area only). I didn''t do this on my current implementation, cause I thought MIDP 2.0 tiledlayer class will handle the view culling automatically.

Share this post


Link to post
Share on other sites
quote:
Original post by frostburn
I don''t know anything about mipd nor java on cell phones, but might it be possible to do view culling by using a simple quad-tree or something?


As I stated in my post, it is impossible to do such optimizations since the TiledLayer does not care about the viewport while drawing, not can you make it care.

The only thing you can do by view culling is to implement your own tilemap class and only draw things that are in the viewport.

Share this post


Link to post
Share on other sites