there are options in there to try spritesheet, basic image or newRect. just comment out the relevant lines in setupTiles()
if it is slow try reducing this line
[lua]local SCREENS = 50[/lua]
(ie currently there 15 cols * 10 rows * 50 screens of “tiles” = 7500 in one big display group)
i optimize my visibility tests by splitting the checks into columns and then checking only columns that have just gone off screen or come onto screen. This means i am not wasting CPU checking items that definitely won’t have changed state
(note do not tap to scroll until the setup has finished,… you should see the fps go stable after a second or two)
(also note, it’s currently set for iPhone 480x320 so you may need to add scale=“zoomEven” etc to the config.lua or adjust the code for your screen dimensions)
So, in an iPod 2g MC, which I think is one of the slowest device around, I got:
With fps = 30 in config.lua
9FPS
without modifications
20FPS
modyfing --> local SCREENS = 5
30FPS smooth most of the time --> local SCREENS = 5 and tile = display.newRect(xpos, ypos, tileWidth, tileHeight) tile:setFillColor(rnd(255),rnd(255),rnd(255))
I’m not sure if this is the kind of info you’re looking for.
[import]uid: 10426 topic_id: 4403 reply_id: 13754[/import]
* create a columns[n] array containing a list of each sprite in that column
* before moving the display group check which items leave, remain, or enter the display area
* move the display group
to optimize the check i only check nearby columns. so say if I am at column 7 as my far left column, my screen is 15 columns wide. so column 21 is the rightmost visible column. and say i’m moving at a speed of 3 columns per frame. On the next movement column 10 will be the leftmost column, but i need to set the sprites in columns 7 to 9 as invisible now. also columns 22,23,24 will now be visible, so i need to set isVisible to true for those sprites. so in this case my minColumn in my code is 7 and my maxColumn is 24… all columns/sprites outside of this area are not even tested as it is an unecessary calculation
this is a very simplified 2-direction example of how Spatial Indexing might work