actionscript - Turn-based Game Loop -


i having lot of headache trying make game loop in actionscript. searched lot , not find answer. idea is:

when de game starts, defined units sequence of attack, based in speed (each player can have until 8 units, of kind). store sequence array. did create engine in javascript returning values in console.log... , works fine... transporting as3, things aren't working thought.

so... have sequence... , loop logic (not using specific language):

for (i = 0; < sequence.length; i++) {      ishitting = sequence[i]; // first unit list hitter     isdefending = mostpowerfulenemy(); // method check attacked      // here problem!!!!     ishitting.moveto(isdefending); // method move mc near target      var kills = ishitting.hit(isdefending); // calc damage , return kills      if (isdefending.amount <= 0) {         // remove mc stage , sequence list        continue; //to move next hitter in sequence      } else {         isdefending.amount -= kills;        continue; //to move next hitter in sequence     } } 

the problem is: units moving @ same time! i've learning events , method addeventlistener() sounds best option, have call function, right? it... unit move point... hit... , stop... need way say: "hey, unit did move, did stop , did hit target, can continue loop" (since cant return continue, ofc)

this want:

animation

some suggestion? sorry bad english.


Comments