Zooming / pinch gesture on tilemap

Hi all

I’m struggling conceptually to get my head round how a zoom tilemap works.

I get tilemaps. The excellent Lime and Tiled makes this a doddle.

However, take a game like clash of the clans where you can zoom in and out of the action. Do you have a very detailed tiled map that you (in the world of the corona SDK) apply some for of object:scale() to and then cull objects that are off screen to help with efficiency?

Or is there another approach?

Some help would be really appreciated

J [import]uid: 103970 topic_id: 31279 reply_id: 331279[/import]

Well, let’s start with the obvious that this is not an answer to your question since I don’t use Lime and don’t know how that would work.

That said, it ain’t the simplest thing and really depends how much you plan to zoom. The issue is that even a modest zoom of 2x will quadruple the amount of objects to handle. Also either you have too big tiles that you scrunch (making things inefficient) when zoomed out or too small tiles that you stretch (making things ugly) when zoomed in. I suspect (without proof) that performance is closer to the total pixels in your textures, not total pixels drawn (ie. drawing at scale of 0.5 is not significantly faster than scale 1.0)

Personal experience is that I have 48x56 hexagons in a ~400x600 view, i.e. ~200 tiles with three layers and 600 graphical objects. That runs smoothly in most devices. Increasing the view to ~520x800 view means ~300 tiles a 50% increase and that is a visible performance hit that only runs in high-end HW. However you can do 1000 24x28 tiles in same size since you’re not increasing drawed texture size.

So like said it’s not easy, you need to experiment and think if you really need it. I.e. it’s probably a sinkhole of hours and you should think if it is really something that will benefit the game and not just a fancy thing. Also think of alternatives like a minimap for navigation. [import]uid: 46570 topic_id: 31279 reply_id: 125061[/import]

Thank you for the reply Matias. I understand the predicament and your guidance is appreciated

I hate to cross reference an alternative SDK but there is a decent article here (http://johnehartzog.com/2009/10/2d-scrolling-game-with-cocos2d-tilemap-with-zoom/) which addresses zoom with a tilemap. The interesting take on this is to create on the detailed view and zoom out. So in theory if you tackle the high detailed view and is optimised (and handle screen culling efficiently) then this seems a sensible approach.

Frustratingly there is an extension that has been written on cocos2d (http://stackoverflow.com/questions/7700538/scrolling-a-tiled-map-in-cocos2d) to handle this very thing.

Anyone in the community got something similar they wish to share? [import]uid: 103970 topic_id: 31279 reply_id: 125140[/import]

Well, let’s start with the obvious that this is not an answer to your question since I don’t use Lime and don’t know how that would work.

That said, it ain’t the simplest thing and really depends how much you plan to zoom. The issue is that even a modest zoom of 2x will quadruple the amount of objects to handle. Also either you have too big tiles that you scrunch (making things inefficient) when zoomed out or too small tiles that you stretch (making things ugly) when zoomed in. I suspect (without proof) that performance is closer to the total pixels in your textures, not total pixels drawn (ie. drawing at scale of 0.5 is not significantly faster than scale 1.0)

Personal experience is that I have 48x56 hexagons in a ~400x600 view, i.e. ~200 tiles with three layers and 600 graphical objects. That runs smoothly in most devices. Increasing the view to ~520x800 view means ~300 tiles a 50% increase and that is a visible performance hit that only runs in high-end HW. However you can do 1000 24x28 tiles in same size since you’re not increasing drawed texture size.

So like said it’s not easy, you need to experiment and think if you really need it. I.e. it’s probably a sinkhole of hours and you should think if it is really something that will benefit the game and not just a fancy thing. Also think of alternatives like a minimap for navigation. [import]uid: 46570 topic_id: 31279 reply_id: 125061[/import]

Thank you for the reply Matias. I understand the predicament and your guidance is appreciated

I hate to cross reference an alternative SDK but there is a decent article here (http://johnehartzog.com/2009/10/2d-scrolling-game-with-cocos2d-tilemap-with-zoom/) which addresses zoom with a tilemap. The interesting take on this is to create on the detailed view and zoom out. So in theory if you tackle the high detailed view and is optimised (and handle screen culling efficiently) then this seems a sensible approach.

Frustratingly there is an extension that has been written on cocos2d (http://stackoverflow.com/questions/7700538/scrolling-a-tiled-map-in-cocos2d) to handle this very thing.

Anyone in the community got something similar they wish to share? [import]uid: 103970 topic_id: 31279 reply_id: 125140[/import]