sqlite in background
I'd like to do some relatively heavy data transformation (mostly inserts and updates) but I'd also would like to run an animation in the foreground (to indicate processing).
Unfortunately I can't find a way to create an asynchronous method so that I can run both the sqlite initialization method and the loading animation (using sprite sheets).
Are there any lua/corona features I'm missing or any work around which I haven't thought of?
Thanks
Replies
@jayantv,
That's what I would have expected, but it didn't work as I thought.
With this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 | local spritext = require "spritext" -- tried also normal sprite animation local loading = spritext.newAnim("loading.png", 60, 60, 1, 8); loading.x = display.contentWidth / 2 loading.y = display.contentHeight / 2 - 30 loading:play() localGroup:insert(loading) local function initialise() db.doInit() -- the databse inputs are here director:changeScene( "intro") end timer.performWithDelay(500, initialise, 1) |
The result is a loading animation for 500ms than the application and the animation (seemingly) block, until the database inserts finish and the scene changes.
I've actually also tried to update the sprite (using loading:nextFrame()) after every insert, but that too did not update.
Any other ideas?
Really, no ideas anyone?
use coroutine Luck :)

@gryzlaw,
depends on what kind of animation, you can have a sprite animation that keeps looping forever and you can stop it when the SQL returns with some data.
the way would be to load the spritesheet and set the animation to loop forever, then run the SQL command and when it completes, then stop the animation.
cheers,
?:)