2

我正在使用带有此代码的 HaxeFlixel来创建过滤器,makeGraphic()而不是图像:

public function new() 
{
    trace('Shield created');
    super();

    makeGraphic(FlxG.width, FlxG.height, FlxColor.TRANSPARENT);
    drawLine(30, 200, 300, 200, { thickness: 2, color: FlxColor.WHITE } );

    var glowFilter = new GlowFilter(0x000000, 1, 10, 10, 3, 1);
    spr2Filter = createFilterFrames(this, glowFilter);
    tween2 = FlxTween.tween(glowFilter, { blurX: 10, blurY: 10 }, 1, { type:            FlxTween.PINGPONG });
    tween2.active = true;
}

override public function update(elapsed:Float):Void
{
    updateFilter(this, spr2Filter);
    super.update(elapsed);
}

function createFilterFrames(sprite:FlxSprite, filter:BitmapFilter)
{
    var filterFrames = FlxFilterFrames.fromFrames(
    sprite.frames, 50, 50, [filter]);
    updateFilter(sprite, filterFrames);
    return filterFrames;
}

function updateFilter(spr:FlxSprite, sprFilter:FlxFilterFrames)
{
    sprFilter.applyToSprite(spr, false, true);
}

问题是它会停止所有动画。如果我只应用过滤器并评论该update()功能,一切都很好,但是发光不是动画。

我究竟做错了什么?

4

0 回答 0