I have something odd happening when I update a FlxSprite's alpha repeatedly to make it fade out. Instead of taking 150 seconds to fade out completely (I actually want 15 seconds), it fades out over maybe 2 seconds. I tried tracing the actual alpha value, and the sprite is invisible when the alpha value is around 0.95 (95% opacity, ie slightly transparent).
Does anyone know how I can get the alpha to work properly in Flixel?
override public function update():void {
lifespan += FlxG.elapsed;
if (lifespan > 3) {
alpha = (1 - ((lifespan - 3) / 150)); // <--- this line
}
if (alpha < 0.01) {
State.s.remove(this, true);
}
super.update();
}
There's a bug in Flixel currently. If an animated sprite is used and the current frame is outside the spritesheet's range, the alpha doesn't work quite right. The same happens if
makeGraphic()
is used.This bug has been logged on the Flixel github issue list, and hopefully it will be fixed in the next version.