Split Enemies Group


(Zouhair Elamrani Abou Elassad) #1

Hi, I’m trying to add some enemies to my screen, this is what i did :

public class LineTrap extend Entity
{

//graphic
[Embed(source = "../../assets/images/trap/ball.png")]
protected static const LINETRAP_ART:Class;	
protected var _lineTrap:Image;

public static var spaceBetween:Number = 10;

public LineTrap(x:Number, y:Number)
{
	_lineTrap = new Image(LINETRAP_ART);
	super(x, y, _lineTrap);
	
	layer = 1;
	type = "lineTrap";
}

//All your custom functions

public static function createHoritzontalLine(x:Number, y:Number, number:Number, world:World)
{
	for(var i=0; i < number; i++)
	{
		world.add(new LineTrap(x + (spaceBetween+graphic.width)*i, y));
	}
}

public static function createVerticalLine(x:Number, y:Number, number:Number, world:World)
{
	for(var i=0; i < number; i++)
	{
		world.add(new LineTrap(x, y + (spaceBetween+graphic.height)*i));
	}
}

}

This class adds a line of enemies on my stage just like this :

Now i want to create a group of enemies that gonna split after a while (or after a specific distance) just like this :

i’m thinking about the best way to do this !


(Martí Angelats i Ribera) #2

To start with you have to determine the way you want them to be generated and how to split. We can’t help too much in this becouse it will depend of the game you’re making.

If you want a explosion this may not be the way to go.


(Zachary Lewis) #3

If you’re making a shmup, I’d recommend writing a frame-based pathing system that tells the groups when to split. If you’re not, I’d recommend writing a controller that controls a group of entities and tells them when to split.


(Zouhair Elamrani Abou Elassad) #4

Sorry for the late answer, i’ve been sick theses last days :s, i managed to do it using The GreenSock tween library, i implemented a diagonal tween :smile:.