对HaxeFlixel的辉光效果

时间:2016-08-21 03:32:05

标签: haxe openfl haxeflixel

我使用HaxeFlixel与此 code 创建一个带有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()函数进行注释,一切正常,但不会对动画进行动画处理。

我做错了什么?

0 个答案:

没有答案