This content has been marked as final. Show 3 replies
I assume that your lengthy AI routines need to be run once at the beginning of a section, rather than repetitively on each frame. If this is the case, then you may be able to spread the process over several frames.
Instead of using a repeat loop, you could use an "on enterFrame()" to process the data. This will mean using a Behavior or an instance of a Parent script, so that you can store the current value of the variables as properties.
If you are unfamiliar with using script instances with properties, I can describe the steps in more detail.
You might like to look at the example at http://nonlinear.openspark.com/tips/other/playDone/. This shows you how a lengthy (but in this case meaningless) process can be treated asynchronousely on stepFrame().
Hey Thanks for the reply. Yes the AI routine is usually run just once but there are many of them. The game is here http://www.crypticcomet.com I have a goal based AI running for a turn based strategy game. The sprites for the UI are just puppeted as needed and the movie runs on a single frame. What is really exasperating is that it works just fine in Windows. Never a stutter. You can process long recursive operations and everything is just fine. On the Mac the background music stutters and freezes. Like I said the updatestage placed strategically can eliminate some of this but not all. What is difference in the way the sound is handled that allows the windows version to handle this smoothly? At this point I can't rewrite the whole turn architecture. Thanks for your help. Don't mean to be complaining.
Just a thought: updateStage 'frees up' Director to update sound & stage etc. In the same way there is a little trick explained in this article that frees it up system resources.
Buddy API also has a similar sleep function to that described in the article. I guess you'd have to use it frequently in the same way as updateStage, but it may be less off a slowdown, or free up the additional resources required