I’m developing a game (sort of a pac man clone) and around the map there are about 800 “pills” - what’s the most efficient way of drawing these?
In obj-c I used to be able to load a single texture and on each screen refresh draw the one texture to all the required positions.
In corona this seems to slow down slightly when running on a device as I’m effectively drawing 800+ sprites (all loaded initially through multiple calls to display.newImage())
Any tips or thoughts for improving speed?
Thanks,
Mal
[import]uid: 13758 topic_id: 6708 reply_id: 306708[/import]
If your level is bigger than the screen (srollable) there is no need to draw all 800 pills at once. I’d use a tile based map then and draw / remove pills dynamically depending if they are inside the visible screen area or not).
Otherwise I’d reduce the amount of pills since 800 objects are way too much to draw at once. [import]uid: 9644 topic_id: 6708 reply_id: 23417[/import]
newSprite will give you benefits if you’re animating your pills etc since you just jump to a frame in the texture (spriteSet), otherwise if you were using newImage, you’d have to remove the image and display a new one. I’m not actually sure how much optimization using newSprite over newImage gives you for single static images. (newImage is cached to texture memory once you load an image once anyway)
I don’t know how Corona’s renderer works compared to the obj-c opengl quad “blitting” you are used to.
I wonder if a feature request for a coordinate blit is worthwhile?
Sorry, jmp, I misunderstood your post because I did not realize that you tried to point out that there should be a speed gain using sprites.
Anyway, I doubt that this will handle 800 screen objects at once, so I would focus on some code optimization instead. [import]uid: 9644 topic_id: 6708 reply_id: 23630[/import]