Skeletal Animation with SWF

Posho

Member
Hello,

I've been making some animations using Spine that have been working fine on GameMaker, but due to the large amount of textures the project size is starting to get a bit heavy, specially considering it's for a mobile game.

All of my animations' textures were done in Flash and the entirety of the textures as SWF files weigh mere kilobytes. So I've been wondering if there could be a way to replace the skeletal animations' textures or Atlas with the individual SWF files imported as sprites.

I know you can create skeleton attachments with sprite indexes. But it seems these are not compatible with the skeletal animation functions (you could, hypothetically, create temporary regular sprites made out of the SWF files using surfaces and make it work).

But as far as I understand right now, there are no real functions that could replace the skeleton's textures with sprites. So is this idea even achievable? Please, some help. :confused:
 

rIKmAN

Member
Spine itself only supports raster graphics, so no.

Also GMS2 only supports a small subset of features of vector files which means unless you have designed your vector art with those restrictions in mind from the start then you will likely be fighting a losing battle from the start. Details of the limitations can be found in the manual.

If your textures are getting too heavy for a mobile game you'll have to look at loading / flushing them as needed to reduce the memory footprint used at any one time, and if that isn't enough then start looking at other ways to optimise.
 

Posho

Member
Spine itself only supports raster graphics, so no.
I know, but is there any way of replacing the textures of an animation with regular PNG sprites?

If your textures are getting too heavy for a mobile game you'll have to look at loading / flushing them as needed to reduce the memory footprint used at any one time, and if that isn't enough then start looking at other ways to optimise.
My concern right now is not run-time performance (it is alright so far), but rather the final disk size of the executable/APK. My textures are the opposite of detailed, so I think SWF files would be perfect since my game requires a lot of zooming in/out. Otherwise, my other alternative is to have the game use a cache for textures and have them fetched from a server before a level starts, but that would still require replacing the skeletal animations' textures with included files' sprites.


This got replied faster than I thought it would be. Thank you! :)
 

rIKmAN

Member
I know, but is there any way of replacing the textures of an animation with regular PNG sprites?
I'm not sure what you mean?
The texture that Spine exports is packed from the regular PNG sprites added in Spine and is already a PNG file.
 

Posho

Member
I'm not sure what you mean?
The texture that Spine exports is packed from the regular PNG sprites added in Spine and is already a PNG file.
Hope it doesn't sound to stupid/insane, but I want to try this out:
  • Export a Spine animation
  • Import the JSON file into GameMaker with a missing or faulty atlas (to reduce the disk space on the project)
  • Import the textures as SWF files separately
  • Before a level starts, create new sprites from the SWFs in accordance to the set game resolution using surface functions, and save them as raster sprites
  • Then finally, somehow replace the textures of the animation with the new sprites that were created
This is to make the app lighter on the initial download and to ensure that the sprites always look smooth no matter the resolution of the phone.
 

rIKmAN

Member
Hope it doesn't sound to stupid/insane, but I want to try this out:
  • Export a Spine animation
  • Import the JSON file into GameMaker with a missing or faulty atlas (to reduce the disk space on the project)
  • Import the textures as SWF files separately
  • Before a level starts, create new sprites from the SWFs in accordance to the set game resolution using surface functions, and save them as raster sprites
  • Then finally, somehow replace the textures of the animation with the new sprites that were created
This is to make the app lighter on the initial download and to ensure that the sprites always look smooth no matter the resolution of the phone.
I'm not sure if GMS2 will allow you to import a skeleton with no sprites - you'd have to try it - but I know there was an issue a while ago where you couldn't even import a skeleton with all slots hidden and had to have at least 1 visible on the default skeleton setup.

Test it with a simple skeleton with a few bones / slots and see if it works.

For the rest of your plan, that would work and you could create attachments on the skeletons using the new sprites, but it seems like a lot more work than just having the raster sprites sprites imported without any of the SWF conversion.

You will also hit the issue that all sprites added will create 1 texture page for every frame of a sprite , which could end up leaving you in a worse position than just using the normal method.

Are you sure you are going to hit issues and have you done any testing?
If not, you may be worrying over nothing and pre-emptively optimizing when you don't need to.
 

TailBit

Member
You could maybe scale it down when exporting from spine to get a small sprite, then scale up the model in GMS
 

Posho

Member
I'm not sure if GMS2 will allow you to import a skeleton with no sprites - you'd have to try it - but I know there was an issue a while ago where you couldn't even import a skeleton with all slots hidden and had to have at least 1 visible on the default skeleton setup.

Test it with a simple skeleton with a few bones / slots and see if it works.
In the YoYo Demo for Skeletal Animation, I just attempted rescaling the texture PNG to a mere 1x1. Surprisingly it ran and the attachments made from sprites worked as well. A step in the right direction, I guess.



For the rest of your plan, that would work and you could create attachments on the skeletons using the new sprites, but it seems like a lot more work than just having the raster sprites sprites imported without any of the SWF conversion.

You will also hit the issue that all sprites added will create 1 texture page for every frame of a sprite , which could end up leaving you in a worse position than just using the normal method.

Are you sure you are going to hit issues and have you done any testing?
If not, you may be worrying over nothing and pre-emptively optimizing when you don't need to.
I am aware that making a system that just might make it all work will be a pain.
Maybe I am overthinking it, but I just want my game to look pretty and don't want to end up with a game that is 1 GB to download.


You could maybe scale it down when exporting from spine to get a small sprite, then scale up the model in GMS
I think that would just make my sprites look horribly due to resizing PNGs back and forth in two separate programs. My textures are not pixel art, mind you.
 
Last edited:

rIKmAN

Member
In the YoYo Demo for Skeletal Animation, I just attempted rescaling the texture PNG to a mere 1x1. Surprisingly it ran and the attachments made from sprites worked as well. A step in the right direction, I guess.
I'm surprised that worked as the json would be referencing areas on the texture page that are out of bounds.
I am aware that making a system that just might make it all work will be a pain.
Maybe I am overthinking it, but I just want my game to look pretty and don't want to end up with a game that is 1 GB to download.
You might save on the download size but as I mentioned the trade off will be performance in terms of having each sprite you load in externally creating a new texture page.
This could end up worse (especially on mobile where texture swaps need to be kept to a minimum) than just having a larger initial download.
I think that would just make my sprites look horribly due to resizing PNGs
Yeah, resizing a small png up will look terrible.

I don't know the specifics of what you are actually trying to do, but it may be an option to create multiple skeletons with the required sprites and load the required one as needed.
The texture pages should be able to be kept pretty small and fine for modern mobiles, but whichever method you go for there will always be a trade off.

As I said I would do some actual testing first as you may be worrying over nothing and spending time trying to solve a problem that doesn't really exist.
 

Posho

Member
You might save on the download size but as I mentioned the trade off will be performance in terms of having each sprite you load in externally creating a new texture page.
This could end up worse (especially on mobile where texture swaps need to be kept to a minimum) than just having a larger initial download.

I don't know the specifics of what you are actually trying to do, but it may be an option to create multiple skeletons with the required sprites and load the required one as needed.
The texture pages should be able to be kept pretty small and fine for modern mobiles, but whichever method you go for there will always be a trade off.

As I said I would do some actual testing first as you may be worrying over nothing and spending time trying to solve a problem that doesn't really exist.
In the end I'm just gonna stay with the regular bone animations with regular textures. The final file size will be leagues larger than if I made it all in SWF, but I don't think like 80 MB for a mobile game is too much.... right?
 
Top