mike470/gtt:“Move the tiles” is one of the bigger “duh” moments in my life. Can’t believe I didn’t think of that one first. Beats the hell out of sprite creation (70ms!) (FWIW, display.newSprite and :setSequence are roughly 70% of the CPU workload of my newTile() function)
Now, gtt, you suggest using translate here, but is it really faster if you have to do the math first to figure out where to translate to? ie: which one of these is faster?
[code]-- 1. Calculate and translate
local distance = map.vis.btm[map.vis.btm.numChildren][32].y - currentRow.y
currentRow:translate(0, distance)
distance = nil
– 2. Set x/y
currentRow.y = map.vis.btm[map.vis.btm.numChildren][32].y[/code]
Each tile is a newSprite(), specifically because I need to be able to animate them. Likewise, it means I use setSequence instead of setFrame. And as luck would have it I’m already using 2 tiles of overdraw on each side so that I can scroll without tiles disappearing on-screen. (Likewise, :prepare is deprecated so wouldn’t use that.)
Results : Well…
- Performance on Simulator (2011 Air OSX) is even worse visually; tons of hiccups. At a glance I’d say the framerate has dropped at least 25% below my previous solution.
- Performance on Device (iPhone4) is clearly better than before. Instead of constant hiccups there is now just a big 300ms hiccup when you change directions but even that seems to go away after awhile.
- In the profiler, the move function has dropped about 15% in performance use (from 1080ms to 890ms)
I’d say there is still something significantly wrong here, but I’ll attach some code and take some suggestions. 
Zwonkie : imageGroup culling has a performance benefit but it does not actually cull the tiles per se. I imagine it’s just using some clever memory sharing. (I’m sure Corona Labs has a better explanation.)
32x32 tile grid (1024 tiles, average Dragon Quest town size): Smooth framerate
64x64 tile grid (4096 tiles, large dungeon): Serious performance issues
256x256 tile grid (65k tiles, world map): Crash device
The key takeaway here is that it does *not* let you skip culling in your code solution. You simply cannot hold so many tiles in memory, let alone translate the entire thing. It’s for this reason that I can recommend Lime for, say, average sidescroller levels but cannot recommend it for an RPG.
[import]uid: 41884 topic_id: 30486 reply_id: 122223[/import]
