Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlxSpriteGroup.set_alpha borked when setting alpha from 0 to 1 #1870

Closed
IBwWG opened this issue Jun 16, 2016 · 3 comments
Closed

FlxSpriteGroup.set_alpha borked when setting alpha from 0 to 1 #1870

IBwWG opened this issue Jun 16, 2016 · 3 comments

Comments

@IBwWG
Copy link
Contributor

IBwWG commented Jun 16, 2016

  • Flixel version: 4.0.0
  • OpenFL version: 3.6.1
  • Lime version: 2.9.1
  • Affected targets:
    windows and flash

Code snippet reproducing the issue:

package;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.group.FlxSpriteGroup;

class PlayState extends FlxState
{
    override public function create():Void 
    {
        var g:FlxSpriteGroup = cast add(new FlxSpriteGroup());
        g.add(cast new FlxSprite());
        g.members[0].makeGraphic(100, 100);
        g.alpha = 0;
        g.alpha = 1;
    }
}

Observed behavior:
Blank.
Expected behavior:
Should see white square, as you would if you commented the last two lines out.

@IBwWG
Copy link
Contributor Author

IBwWG commented Jun 16, 2016

This is likely caused by this line in FlxSpriteGroup.hx:

var factor:Float = (alpha > 0) ? Value / alpha : 0;

I have two questions about this:

a) what's the purpose of it? (@Gama11 apparently it's from you, can you help me understand the intention?)
b) in the above example, how come it doesn't cause a divide by zero error? instead it passes 0 on as the value of factor to the next function, which then sets the alpha to 0, causing the above broken behaviour

@Gama11
Copy link
Member

Gama11 commented Jun 16, 2016

Duplicate of #1353.

@IBwWG
Copy link
Contributor Author

IBwWG commented Jun 16, 2016

Sorry! I searched before the last bug, forgot to search this time. With that title I definitely would've found it! Whoops!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants