setColorTransform flickering when applies on a typed group

  • Hi!
    I am trying to create something like Galaxian.
    I have enemy spaceships that I store in var enemies:FlxTypedGroup<Enemy>;
    When bullet overlaps an enemy I call

    	public function onOverlap()
    		this.setColorTransform(1, 0.4 + (HP / 10), 0.4 + (HP / 10));
    		if (HP <= 0)

    this is what happens in the playstate loop:

    override public function update(elapsed:Float)
    		FlxG.overlap(enemies, playerBullets, onOverlap);
    	function onOverlap(enemy:Enemy, bullet:Bullet)
    		if (enemy.alive && enemy.exists && bullet.alive && bullet.exists)
    			if (enemy.alive == false)
    				explosion = new Explosion(enemy.x, enemy.y);

    Seems I do everything right but after the first overlap all my enemy spaceships starts flickering and disappear...
    And it looks like a complete chaos.
    I have no idea how I can fix the issue... could anybody help to resolve?

  • Solved.
    As I am using typed group to store all my enemy ships I have to set Unique for loadGraphic in my Enemy class everytime I create a new instance.
    Otherwise HF optimizes memory usage and store only one graphic object in vertex buffer and when I try to repaint one particular enemy it overloads the vertex buffer.
    The following resolved the issue (one small 'true' at the end):

    loadGraphic("assets/images/enemy.png", false, 24, 22, true);

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.