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

FlxAnimation doesn't play in reversed mode #1989

Closed
DrDerico opened this issue Oct 29, 2016 · 7 comments
Closed

FlxAnimation doesn't play in reversed mode #1989

DrDerico opened this issue Oct 29, 2016 · 7 comments

Comments

@DrDerico
Copy link

DrDerico commented Oct 29, 2016

  • *Flixel version: * 4.2.0 and dev
  • OpenFL version: 3.6.1
  • Lime version: 2.9.1
  • Affected targets: all

Observed behavior:
Animation freezed on Frame 0
Expected behavior:
Animation must be play in reversed mode

The problem is in FlxAnimation.set_curFrame method.
If I use code for set_curFrame from flixel 3.3.5, the animation works as expected.

@Beeblerox
Copy link
Member

Please provide code example.
Btw, in flixel 3.3.5 there wasn't such feature as playing animation in reverse mode

@DrDerico
Copy link
Author

Саш, the code example is very simple.

I already localized the problem code. It's a "set_curFrame" function.

You should just compare two codes from different versions of Flixel.

4.0.0 (I think. Yes, it's not 3.3.5):

private function set_curFrame(Frame:Int):Int
    {
        var numFramesMinusOne:Int = numFrames - 1;
        // "reverse" frame value (if there is such need)
        var tempFrame:Int = (reversed) ? (numFramesMinusOne - Frame) : Frame;

        if (tempFrame >= 0)
        {
            if (!looped && tempFrame > numFramesMinusOne)
            {
                finished = true;
                curFrame = (reversed) ? 0 : numFramesMinusOne;
            }
            else
            {
                curFrame = Frame;
            }
        }
        else
        {
            curFrame = FlxG.random.int(0, numFramesMinusOne);
        }

        curIndex = _frames[curFrame];

        if (finished && parent != null) parent.fireFinishCallback(name);

        return Frame;
    }

And current version:

private function set_curFrame(Frame:Int):Int
    {
        var maxFrameIndex:Int = numFrames - 1;
        if (reversed)
            Frame = (maxFrameIndex - Frame);

        if (Frame >= 0)
        {
            if (!looped && Frame > maxFrameIndex)
            {
                finished = true;
                curFrame = reversed ? 0 : maxFrameIndex;
            }
            else
            {
                curFrame = Frame;
            }
        }
        else
            curFrame = FlxG.random.int(0, maxFrameIndex);

        curIndex = frames[curFrame];

        if (finished && parent != null)
            parent.fireFinishCallback(name);

        return Frame;
    }

As you see in new version there is no "tempFrame" variable and "Frame" is changed immediately that cause the problem.

@Beeblerox
Copy link
Member

@DrDerico yes, i think you're right about tempFrame variable.
PR then?

@DrDerico
Copy link
Author

DrDerico commented Nov 12, 2016

PR then?

I don't understand what is PR :/

@Beeblerox
Copy link
Member

Pull Request :)

@DrDerico
Copy link
Author

ok, do what you think you should do :)

@Beeblerox
Copy link
Member

fixed in 05cde21

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