actionscript 3 - AS3 enemy formations -


i have been developing shooter game in as3 using starling framework looking @ different tutorials. problem tutorials teach create random enemies move 1 side other. want know how can create different formations of enemies on screen.

can suggest books, tutorials, or basic algorithm put me on track?

here rather simple way spawn formation.

create symbol in library called formation , use linkage/class name well.

in symbol place 5 marker movieclips @ whatever locations want. marker clip recommend using circle centered. wherever place markers, represents enemies spawned.

now, in code want spawn formation, can :

var formationdata:movieclip = new formation; (var index:int = 0;index < formationdata.numchildren;index++) {     var spawnmarker:movieclip = formationdata.getchildat(index) movieclip;     var enemy:enemy = new enemy;     enemy.x = spawnmarker.x;     enemy.y = spawnmarker.y;     addchild(enemy); } 

now, spawn formation based on set in formation symbol.

you can offset location of enemies spawned doing :

var offsetx:number = 200; var offsety:number = 50; (var index:int = 0;index < formationdata.numchildren;index++) {     var spawnmarker:movieclip = formationdata.getchildat(index) movieclip;     var enemy:enemy = new enemy;     enemy.x = offsetx + spawnmarker.x;     enemy.y = offsety + spawnmarker.y;     addchild(enemy); } 

what concept allows do, visually layout formations in flash ide. create whole bunch of different formations , choose random one. have spawn points spell out word ?

obviously code above example, need integrate concept spawn system etc.

depending on enemies spawning from, might need use offset start them offscreen.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -