How to create animated sptite dynamically?

  • Hi!

    In the HaxeFlixel I can load spritesheet for animations by Sprite.LoadGraphics().
    Now I need to use for animations the sprite that was created by Sprite.MakeGraphics() and filled programmatically.
    How to do this?


  • Check this out:
    The whole thing is worth the read, but just so you know
    loadgraphics(); is used to load the sprite sheet
    animation.add(); is used to add animation sequences
    Just read the documentation you'll understand how it works C:

  • Thanks. but it's not that. When you create graphics through LoadGraphics() - you can create multiple frames, which can be switched through Sprite.animation.frameIndex (and these frameIndexes are loaded in animation.add ()). When you MakeGraphics(), you do not have several frames.

  • administrators

    loadGraphic() accepts BitmapData as it's Graphic argument, so you could probably use makeGraphic() and then call loadGraphic(pixels, true, <width>, <height>) immediately after.

  • @Gama11
    Thanks! Will surely try such option.
    Also, I just have looked into the sources (just forget about them :)) and saw inside it FlxTileFrames.fromFrame() which also solves the problem.
    Thanks again! )

Log in to reply

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