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

Calling revive on FlxSpriteGroup won't set children to alive. #1891

Closed
caiopsouza opened this issue Jul 25, 2016 · 2 comments
Closed

Calling revive on FlxSpriteGroup won't set children to alive. #1891

caiopsouza opened this issue Jul 25, 2016 · 2 comments
Milestone

Comments

@caiopsouza
Copy link

caiopsouza commented Jul 25, 2016

  • Flixel version: 4.1.0
  • OpenFL version: 3.6.1
  • Lime version: 2.9.1
  • Affected targets: All

Code snippet reproducing the issue:

package;

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

class MenuState extends FlxState
{
    override public function create():Void
    {
        super.create();

        var group = new FlxSpriteGroup();
        var amount = 10;

        for (_ in 0...amount) group.add(new FlxSprite());
        trace(group.length, group.countLiving(), group.countDead());

        group.kill();
        trace(group.length, group.countLiving(), group.countDead());

        group.revive();
        trace(group.length, group.countLiving(), group.countDead());
    }
}

Observed behavior: Last line printed is "10,0,10"
Expected behavior: Last line should be "10,10,0"


This happens because FlxSpriteGroup.set_alive will check if the object "exists" before changing its value. A quick fix would be to swap those two line in FlxBasic so "exists" will be true when it tries too change the value of "alive".

Using FlxSpriteGroup for FlxGroup the result is as expected.

@thegoodideaco
Copy link

can this be fixed? I'm running into issues because of this, and it seems like a very easy fix, it's been an issue for about a month now.

@Gama11
Copy link
Member

Gama11 commented Aug 22, 2016

A quick fix would be to swap those two line in FlxBasic so "exists" will be true when it tries too change the value of "alive".

Sounds like a hack to me. I see no good reason why set_alive() needs to check for exists in the first place.

@Gama11 Gama11 added the Bug label Aug 22, 2016
@Gama11 Gama11 added this to the 4.2.0 milestone Aug 22, 2016
@Gama11 Gama11 closed this as completed in c2ac5e5 Aug 22, 2016
Aurel300 pushed a commit to larsiusprime/haxeflixel that referenced this issue Apr 18, 2018
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

3 participants