animation.frameName not working



  • Hi there,

    I'm a long time user of Flixel, but new to HaxeFlixel and currently working on porting some code to Haxe. I'm trying to import my animations from a libgdx texturepacker export using methods shown here: https://github.com/HaxeFlixel/flixel-demos/blob/master/Editors/TexturePackerAtlas/source/MenuState.hx

    The issue I'm running into is that animation.frameName doesn't seem to be updating when I set it. The following will output casper-down, which is the name of the first region in my atlas.

    Player.hx (extends FlxSprite)

        texture = FlxAtlasFrames.fromLibGdx(Constants.packDir + "Sprites.png", Constants.packDir + "Sprites.atlas");
        frames = texture;
    
        animation.frameName = "Casper-standing2";
        trace(animation.frameName);
    

    It's worth noting that I am seeing sprites from my packed image, they are just not from the correct region. Can anyone tell me where I'm going wrong?

    Thanks!



  • Ok, for anyone running into a similar issue in the future:

    TL;DR: Use animation.addByPrefix, and make sure your animation frames are separate regions within the packed png (walk-01, walk-02, etc).

    I gave up on trying to use animation.frameName for this, no matter what I do I cannot get the correct region to load in. The only method that I could get to work with fromLibGdx was animation.addByPrefix.

    In my existing game each region within the packed image is a spritesheet, rather than an individual fram and the game adjusts the frameHeight / frameWidth of the sprite for the animation, unfortunately this method doesn't work now since addByPrefix adds an entire region as a frame so I am exporting all of my animations as individual frames to be packed by texturepacker.


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.