Question regarding tile maps and sprites

Just wondering about possible resource problems if I create a large tile map from a sprite sheet.

If I create a 100 * 100 tile map from images held in a sprite sheet does it mean I will have a single image in memory or 10,000? [import]uid: 9371 topic_id: 4027 reply_id: 304027[/import]

I think so. If you load it, it stays in memory as one sheet. [import]uid: 11024 topic_id: 4027 reply_id: 12290[/import]

That’s not quite right. he’s talking about taking a sprite sheet and rendering a tile map of multiple sprites. I don’t know what corona does internally but even if it did render this group as a new texture there’d still be a dinension limit (1024x1024 or something like that?). The answer is we don’t really know how coronas rendering techniques work, you’ll have to wait for ansca to answer this [import]uid: 6645 topic_id: 4027 reply_id: 12318[/import]

Sorry, I misinterpreted what he wrote. Actually, Corona is pretty smart when it comes to reusing objects. For example, right now I’m building an diamond isometric tiler and there’s no difference in the texture memory usage between 10 or 100 tiles on screen. [import]uid: 11024 topic_id: 4027 reply_id: 12324[/import]

Of course there is no texture memory difference because the image just needs to be loaded once only -but much more interesting is how sprite sheet tiles behave performance-wise. Does it cost more performance than handling “single” images?

I wonder if there’s an ANSCA programmer around here which could give us some technical “under the hood” details on how Corona manages graphics and how efficient sprite sheets are from an internal sight.

I’d also be interested if we should care about draw calls (texture swaps) in Corona. If so, it wouldn’t be recommended to use many different single images. It would be better then to collect all images in texture atlases (sprite sheets). [import]uid: 9644 topic_id: 4027 reply_id: 12325[/import]

I’ve asked Ansca and will post the answer here. I’m porting a game I wrote for Windows Mobile (also written in a Lua framework) that uses this technique and it runs fine with large tile maps but how that implemented under the covers compared with Cotrona I have no idea.

[import]uid: 9371 topic_id: 4027 reply_id: 12342[/import]

Yes the performance is noticeably worse, especially on the device. Partially dependent on your implementation and working around the encapsulation of the fps forced timer and most functions in corona.

I’ve separated calculations and functions that force immediate draws with a time-based loop within my run time and it works alright at 30fps with moving 250 tile objects on screen.

They don’t recommend this approach (saying you should use transition.to instead of manually moving objects) but when using a joystick, there isn’t much choice. [import]uid: 11024 topic_id: 4027 reply_id: 12379[/import]

Should note that under 60fps, the 250 moving tile objects drop to 40fps.
Under 30fps setting, it stays consistent at 30fps minimum.

When doubling that number, it slows to 23 fps minimum on the 30fps setting. [import]uid: 11024 topic_id: 4027 reply_id: 12380[/import]

Would be great to see an Ansca example of how to use tile maps – COME ON GUYS! [import]uid: 9371 topic_id: 4027 reply_id: 12381[/import]

@finnk: did you move the objects individually or did you put them into a group and move that single group then? I wonder if performance could be improved by grouping objects and moving them as a group. [import]uid: 9644 topic_id: 4027 reply_id: 12420[/import]

They’re moved as a group. I’m actually pretty happy with that performance. Getting 500 onscreen tiles to move at 24fps is not bad, but I think I can do better.

I’m just not familiar with the event listeners all doing their own thing so I have to rethink my design approach. My problem is partially in using the runtime as a game loop. It’s forced to the config FPS so no matter what, you only get 60 or 30 updates/second. As you can guess, forcibly translating the objects by x and y at this rate of update is kind of odd. That’s fine for drawing, but for calculations, it gets weird. If I used a closed while loop, I can get 17000 updates, but then none of the listeners work and the Corona simulator can’t even quit via its own shortcuts.

I believe that if I use transition.to, I should have no problems though. Currently rebuilding this engine from the bottom up.
[import]uid: 11024 topic_id: 4027 reply_id: 12421[/import]

I still think it would be very useful if Ansca could give us an example of how to sue tile sheets [import]uid: 9371 topic_id: 4027 reply_id: 12427[/import]

I’m finding that the simulator is very jerky and the device is a little jerky when using tile maps with sprites, and it’s only about 100 tiles :frowning:

[import]uid: 9371 topic_id: 4027 reply_id: 12461[/import]

upload your code!

don’t have a device at the moment, but i can see if i can think of anyway of optimizing the code

www.sendspace.com

[import]uid: 6645 topic_id: 4027 reply_id: 12473[/import]

I just changed my transformations to transition.to.

716 objects - 12fps minimum, 18 average, jarring and eventual freezing
537 objects - 17fps minimum, 23 average, jittery
358 objects - 24fps minimum, 29 average, jittery or ghosting

Yeah I think I might have been better off controlling this manually.
The framerate seems consistent with the device performance, but it’s jittery animation. [import]uid: 11024 topic_id: 4027 reply_id: 12479[/import]

This jittery display is getting me down too. It means my game is dead in the water [import]uid: 9371 topic_id: 4027 reply_id: 12487[/import]

i came across some very confusing results…

i’m rendering tiles in my setup and setting them to isVisible=false,

then in my update I check tiles are within the screen area and set isVisible=true… now here’s the odd thing, if i say “else tile.isVisible=false” then my fps slows down from 60 to 30

see my post here about it:
http://developer.anscamobile.com/forum/2010/11/13/performance-tip-setting-isvisiblefalse-slow-reading-display-object-xy-slow [import]uid: 6645 topic_id: 4027 reply_id: 12501[/import]

i’m getting 1600 objects (all the same, not spritesheet at the moment) moving at 60fps on the simulator

could someone test this on device please… (tap to restart)

souce code:
http://www.sendspace.com/file/0vndga

android 2.2 apk on bit.ly:
http://bit.ly/hHbbtl

(not sure if that’ll download without the extension in the bitly url?) [import]uid: 6645 topic_id: 4027 reply_id: 12563[/import]

On the simuator it drops to 30 (min 20) after a while and the display is very jittery! [import]uid: 9371 topic_id: 4027 reply_id: 12565[/import]

Sent to my tame beta tester, running a HTC Desire, will report back… [import]uid: 9371 topic_id: 4027 reply_id: 12566[/import]