It looks like you're new here. If you want to get involved, click one of these buttons!
if self.searchFuncTask then
if status=="dead" then
-- When search is complete coroutine terminates and we can
-- make the bot's move.
-- Search continuing
I think you will use threads for animations or to chance something on the scene after sometime. In these languages like as3 and lua, they have enterframe event instead of thread. You can have a look at the examples on the starting page of the gideros studio. Then you can easily understand enterframe event.
For animations , You can use movieclips also. In the tutorials you will able to find its examples.
However , if you want to use thread for other things , there isn't such a code in lua. But you can also create it by the calling a method in the enterframe. for example;
if play then
if play then
if counter==time then
It should be something like that. I didnt try it on Gideros. Actually , it is not same as real thread.
BTW , using thread is not good for programming. You should use timers or (as i said before) Enterframe event (Fps).
However, it is possible to use co-routines fairly easily from Lua if you take a little care. Coroutines are like parallel processes except that they aren't pre-emptive. This means that the OS doesn't allocate a time slice to each one or allow a higher priority process to take over automatically from a lower priority one.
So what you have to do is run your process (coroutine) for a short time and then it must ask to yield() itself. This must be done inside an ENTER_FRAME event (which is triggered 60 times a second) and the "short time" must be very short if you don't want to cause your animations to stutter. Basically, while your coroutine is running, all Gideros animations will pause.
I have used this approach in a game that I'm working on to allow animations to continue while an AI Bot does some background working out. Basically, I resume the coroutine in the ENTER_FRAME handler and make a note of the time. As the coroutine works it continuous monitors the time and when 1/30 sec has elapsed it yields itself. This causes the frame rate to drop from 60fps to 30fps while the Bot is working. The animations look slightly "sticky" but are nowhere near as bad as if I didn't use the coroutine at all.
Here's an example of my onEnterFrame() handler: