Weird BlendMode stuff??

39 views
Skip to first unread message

Will Blanton

unread,
Apr 22, 2016, 7:53:50 PM4/22/16
to HaxeFlixel
So for some reason, sometimes when I change the blend property of some sprites, it works exactly how I'd expect, but for others, it looks like it's setting the blendmode for every object in the state when it comes on screen.

In this gif, the player walks up to the torch object twice - the first time, a circle sprite has the blendmode set to NORMAL, in the other, ADD. The flames on the torch are set to ADD, so like I said, it only seems to happen with certain sprites. (Both the flames and the circle are FlxSprites)

Any advice?

Thanks!

Gama11

unread,
Apr 23, 2016, 4:59:47 AM4/23/16
to HaxeFlixel
What target? Any code to reproduce?

Will Blanton

unread,
Apr 23, 2016, 2:00:48 PM4/23/16
to HaxeFlixel
it's only happening on native (or at least Windows) targets, and the sprite code itself doesn't reproduce in other projects. Maybe it's just time to start this project fresh again :P

Will Blanton

unread,
Apr 23, 2016, 2:04:07 PM4/23/16
to HaxeFlixel
but just in case

class Circle extends FlxSprite
{
public var on:Bool;
var addMode:Bool = false;
public function new(_p:FlxPoint):Void
{
super(_p.x - 16, _p.y - 16, "assets/images/lightSource.png");
//blend = BlendMode.ADD; // TODO: wtf? why does this not work?
alpha = 0;
}
override public function update(elapsed:Float):Void 
{
if (on && isOnScreen())
{
var s = ZMath.randomRange(0.75, 1);
scale.set(s, s);
if (alpha > 0.2) alpha -= 0.025;
else if (alpha < 0.1) alpha += 0.025;
else alpha += ZMath.randomRange( -0.025, 0.025);
}
else
{
if (alpha > 0) 
{
var s = ZMath.randomRange(0.75, 1);
scale.set(s, s);
alpha -= 0.01;
}
}
super.update(elapsed);
if (FlxG.keys.justPressed.P)
blend = blend == BlendMode.ADD ? BlendMode.NORMAL : BlendMode.ADD;
}
}



On Friday, April 22, 2016 at 7:53:50 PM UTC-4, Will Blanton wrote:
Reply all
Reply to author
Forward
0 new messages