HaxeFlixel / HaxeFlixel/flixel
animation.play() with Reversed==true not working as expected
Open
Nobody has claimed this yet.
- Dominant language
- Haxe
- Stars
- 2.2k
- Forks
- 522
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Description
- Haxe version: 3.4.2
- Flixel version: a5cb05d
- OpenFL version: 3.6.1
- Lime version: 2.9.1
- Affected targets: flash, neko
Code snippet reproducing the issue:
package;
import flixel.FlxState;
import flixel.FlxSprite;
import flixel.util.FlxColor;
class PlayState extends FlxState
{
override public function create():Void
{
var playerSprite = new FlxSprite();
playerSprite.makeGraphic(100, 100, FlxColor.GREEN);
add(playerSprite);
playerSprite.animation.add("test", [0, 0, 0, 0], 6, false);
playerSprite.animation.callback = function(name, number, index) {
trace("callback", playerSprite.animation.finished, name, number, index);
};
playerSprite.animation.play("test", true, true);
}
}
Observed behavior:
On Flash:
PlayState.hx:45: callback,false,test,3,0
PlayState.hx:45: callback,false,test,2,0
PlayState.hx:45: callback,false,test,1,0
PlayState.hx:45: callback,false,test,0,0
PlayState.hx:45: callback,false,test,-1,0
PlayState.hx:45: callback,false,test,-2,0
PlayState.hx:45: callback,false,test,-3,0
PlayState.hx:45: callback,false,test,-4,0
PlayState.hx:45: callback,false,test,-5,0
PlayState.hx:45: callback,false,test,-6,0
PlayState.hx:45: callback,false,test,-7,0
...
On neko:
PlayState.hx:45: callback,false,test,3,0
PlayState.hx:45: callback,false,test,2,0
PlayState.hx:45: callback,false,test,1,0
PlayState.hx:45: callback,false,test,0,0
Invalid operation (%)
Called from flixel.animation.FlxAnimationController::set_frameIndex line 725
Called from flixel.animation.FlxBaseAnimation::set_curIndex line 32
Called from flixel.animation.FlxAnimation::set_curFrame line 243
Called from flixel.animation.FlxAnimation::update line 197
Called from flixel.animation.FlxAnimationController::update line 87
Called from flixel.FlxSprite::updateAnimation line 629
Called from flixel.FlxSprite::update line 621
Called from flixel.group.FlxTypedGroup::update line 141
Called from PlayState::update line 59
Called from flixel.FlxState::tryUpdate line 172
Called from flixel.FlxGame::update line 735
Called from flixel.FlxGame::step line 665
Called from flixel.FlxGame::onEnterFrame line 538
Called from openfl._legacy.events.EventDispatcher::dispatchEvent line 98
Called from openfl._legacy.display.DisplayObject::__dispatchEvent line 182
Called from openfl._legacy.display.DisplayObject::__broadcast line 161
Called from openfl._legacy.display.DisplayObjectContainer::__broadcast line 286
Called from openfl._legacy.display.Stage::__render line 1103
Called from openfl._legacy.display.Stage::__checkRender line 351
Called from openfl._legacy.display.Stage::__pollTimers line 1084
Called from openfl._legacy.display.Stage::__doProcessStageEvent line 430
Expected behavior:
Should be same as when Reversed==false (but with reversed frame order):
PlayState.hx:45: callback,false,test,3,0
PlayState.hx:45: callback,false,test,2,0
PlayState.hx:45: callback,false,test,1,0
PlayState.hx:45: callback,false,test,0,0
PlayState.hx:45: callback,true,test,0,0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the supplied PlayState snippet on Flash and neko, then start at flixel.animation.FlxAnimationController::set_frameIndex (line 725) and follow FlxBaseAnimation::curIndex and FlxAnimation::update. Done means reversed playback stops at frame 0, invokes the callback with finished=true once, and does not produce invalid modulo errors.
Written by the indexing model from the issue text.
Assessment
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100