one stop for all game coders..
| Some AI using timer object |
|
|
| Written by CR Team | |||||||||
| Thursday, 13 August 2009 13:35 | |||||||||
|
One can create some basic AI game logic using the timer objects available in Adobe Director scripting using the timeOut() method. Say you have a bunch of enemies to be spawned and they have to shoot continuously after a specific interval,( say a enemy ship approaching a hero ship ), you can create a timer object that would call a method specified after the given interval in milliseconds. The following code snippet will walk you through the process:
In the above code snippet, #_init_enemy and #missileFire are user defined functions that will be called when the timer tick is completed. Say you have specified the alien_spawn to be 3000 ms, the _init_enemy() function will be called every 3 seconds. Once the above code is setup one can define the function and go about the game logic:
Suppose you want to remove the timer just call the forget() method with the timer name:
Hope this was helpful. Share more ideas if any at our forums :)
|