GMS 2 Optimizing SWF Animation (Animate export/GAF)

Discussion in 'Advanced Programming Discussion' started by Trasoside, Oct 10, 2018.

  1. Trasoside

    Trasoside Member

    Jun 25, 2016
    *In short, this topic is simply for those who want to stick with Adobe Flash/Animate (instead of spine)*

    Alright so, me and my team were working on a huge project with tons of swf content made in flash (for mobile devices).
    At the beginning, we just exported everything from flash to png, loaded it as sprites in GM, and it worked just fine.
    the CONs in doing so are:
    -final apk size becomes huge. (over 100mb)
    -all sprites are automatically loaded into ram when game is opened (over 200mb)
    -loading big animations/backgrounds takes tons of time. (solved by sprite_prefetch, but still causes game to lag)
    -managing all these sprites is hell, sometimes, we'd rather put 1 sprite in 1 texture group, so all it's images will end up on the same texture page.

    of course, all these cons could be solved by simply using spine (well spine has it's cons too..). but our animators knows only flash and all animations were already done in flash.
    we tried using the SWF option GMS offers, but final result is just bad, (for example, black outlines surrounds swf vectors? + it doesn't looks like it is very efficient in terms of cpu/gpu usage)
    swf bug example:
    upload_2018-10-10_5-36-18.png instead of : upload_2018-10-10_5-36-39.png

    anyways, what I'm trying to say is, that the current SWF option GMS offers, is not ideal, and there are few alternatives out there that I've found, instead of drawing vectors real time, they convert vector objects to pngs, order them in a texture page, and exports additional data to read them from that texture page and draw them correctly. I think this method might be even faster than spine, because it's just data of frames and doesn't seems like it uses bones/ease logic.

    this image can sum up the idea:

    here are 2 tools I've tested that can make such thing:
    a) first one is "Generate Texture Atlas" in Animate CC which exports a texture page, together with spritemap.json (to map the texture page) and animation.json (to map the animation frames) both are kinda readable.

    b) second one is "GAF" , i tried testing this tool and it looks like it does simply the same thing as the "generate texture atlas" (maybe offers some better optimizations?-not sure about that yet). it exports a texture page, combined with a .gaf file (binary file that contains both sprites data and animation data)

    both tools already supports engines such as Unity, Starling, Cocos etc.

    So, for the moment. I have a few questions:
    1) Did anyone find an efficient way to play swf animations properly in GM?
    2) How possible do you guys think it is to implement one the alternatives I've found above? maybe we as a community can come up with a solution?
    3) I've tried searching google for ways to export from flash and import to spine, but it doesn't seems like they want to support it, if anyone ever succeed to to do something like it and can share his experience, it might be super appreciated and helpful. even Dragon Bones or Spriter flash import can be useful.

    sorry for the long text. hopefully this discussion will lead to something epic and help many others on the way.
    any piece of info is appreciated. thanks. Rom
  2. sylvain_l

    sylvain_l Member

    Sep 18, 2016
    OK, wrong assumption : GM doesn't support native swf.

    all it does is translate the information into a - I assume - kind of vertex buffer. With one basic GM timeline (or something else).

    that means all curves are translated into polylines which means you require a lot of point to have something that resemble to a circle. Or any curve.

    does only support 1 timeline (if you use multiple to handle your swf animation you'll run into problem)
    and of course doesn't support any actionscript

    also GM doesn't handle well gradient
    same goes for most advanced feature (variable outline boldeness, etc... I'm pretty sure too advanced animation feature certainly are not all supported.)

    so if you dreamed of making wonderfull flash anim and import them "as is"; not going to happen, you'll have to adapt your workflow and art style to what GM support. sorry.
    Or move to unity.^^

    me too would have loved to see spine support vector graphic but's not on their calendar :(

    p.s.2 I think you already read it:
  3. Trasoside

    Trasoside Member

    Jun 25, 2016
    Hi thanks for the info, thing is I don't mind if the animation won't be drawn as vectors, as long as it draws properly. Thats why I suggested gaf and animate export atlas option. So we could play our flash animations properly in gm. The results these tools gave me were perfect. Just need to figure out a way to play them in gm.
  4. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Apr 21, 2016
    People have done an extension for Spriter (other skeletal animation tool) in past so likely possible - a matter of someone with enough experience being able to devote enough time to the matter.

    You can also take a look at DragonBones - it can import animations from Flash and IIRC can export to Spine format, which would allow you to play them in GM.
  5. Trasoside

    Trasoside Member

    Jun 25, 2016
    I fought with dragon bones and spriter trying to import swfs.. google doesn't help either..
    I think only way would be to implement a .GAF/Adobe Animate's "Generate Texture Atlas" output to Spine tool
    or to implement some scripts that could read .GAF/Adobe Animate's "Generate Texture Atlas" output in Game Maker.
    Adobe Animate's "Generate Texture Atlas" output
    seems kinda readable, I believe it is possible to read and draw it's data with GM scripts.

    if anyone is interested in Adobe Animate's "Generate Texture Atlas" output:
    there are attached files at the bottom of this page :
    the json that maps the images is kinda easy to read
    the json that maps the animation is a little more complicated.. but I believe it is possible to implement somthing in gm that reads that..

    maybe I'll give it a shot one day..
  6. jackal

    jackal Member

    Nov 16, 2018
    I have been building an Animate CC export tool alongside a GML runtime for my project. The tool works similar to Dragon Bones and GAF, in that it exports texture atlases alongside keyframe data to reconstruct Animate CC animation. Here is a basic HTML Canvas prototype of the tool:

    I am planning on releasing the tool to the marketplace. It won't be free but I think it will provide a lot of value to the community. Here are some of the planned features:

    - Nested MovieClip animation
    - Accurate animation reproduction
    - Texture packing, with optional support for TexturePacker, polygon packing, and multi resolutions
    - Very basic API with minimal assumptions (I won't be implementing full display list functionality, but instead be providing a minimal draw API that can be easily extended)
    - Drawing "hooks", for swapping out symbols at runtime, or custom draw functionality
    - Full source code for the exporter, so it can be adapted for specific game needs

    I have seen a few posts here and on the GameMaker subreddit regarding an Animate CC exporter. Having a Flash background I find the current range of animation tools for GameMaker rather limiting and cumbersome. I'm hoping this tool can provide an all-encompassing asset workflow for people like me who still really value Animate CC for its animation tools.
    nesrocks likes this.
  7. Trasoside

    Trasoside Member

    Jun 25, 2016
    Wow, bro, it looks awesome! It looks like the demo is working just fine!
    Is there any way I can help you with finishing it? I would be thankful to test it or help you in any way...
  8. jackal

    jackal Member

    Nov 16, 2018
    That would be great if you are able to test and provide feedback. I am still ironing out a lot of kinks and bugs, but I am making decent progress. When I have a workable beta ready I will get in touch :)

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice