I’m trying to create a bullet hell and I’m getting frame drop issues (from 60->30ish) with as little as under 200 bullet entities. So I’m having some trouble. I’m currently using basic recycling with the code looking like:
public function PlayerShot()
{
_image = new Image(Assets.littleTriangle);
_image.centerOO();
graphic = _image;
setHitbox(10, 10, 5, 5);
type = "PlayerShot";
layer = GC.LAYER_BULLETS;
}
And in the parent class Shot(), there’s a function
public function CreateShotA1(x:Number = 0, y:Number = 0, speed:Number = 0, angle:Number = 0, delay:Number = 0):void {
this.x = x;
this.y = y;
_speed = speed;
_angle = angle;
_delay = delay;
}
And this is the code in the player class is:
if (shotDelay > 0) shotDelay -= FP.elapsed;
else if (Input.check("SHOT")) {
shotDelay = 0.02;
for (var i:int = 0; i < 32; i++) {
var _shot:PlayerShot = FP.world.create(PlayerShot) as PlayerShot;
_shot.CreateShotA1(x, y, 1600, i * 11.25);
FP.world.add(_shot);
}
}
So I’m quite envious of the mythical 1.5k or so entities that I hear about people achieving, and I’m wondering how to optimize or what to utilize to achieve it. I hear about object pooling with linked lists or whatever, but I figured recycling with the basic flashpunk stuff would be enough. Any ideas?