SWF Properly Done

J

jason_Evans

Guest
I have created a few games now and I have learned much about the fundamentals of GMS (1.4 currently still), and I wanted to try to take on what many have left behind.......vectors. I know many have had success with this in GMS, and I have seen some impressive artwork in-game also. But, so many have steered away from vectors for good and bad reasons. The bad reason is that vectors can actually be utilized very well! The good news is, for those with 60fps stability and Delta functions can see likely little improvement over standard rasters with transparency, such as png, gif, and bmp.

I have found, over the past 2 months playing with more fun features in GMS, that vectors can prove a great asset. There is quite a bunch of planning ahead though. In the end, I am finding it worth my time, though others with pixel_art graphics and proper scaling techniques may just stop here because who doesn't like a good, functional, well-written pixel game anyway?! They are coming back quick in the 2d world at the moment.
stars vector in inkscape.PNG


Anyhow, for those who want to try....and I mean only try atm....some vectors for both static and movement objects(of slower movement mainly beneficial), here is how I got it working just right!


Programs needed
a. GMS
b. Inkscape or GIMP (inkscape is proving more reliable, as GIMP crashed and deleted my entire last project worth 3+ months of work after exporting SWF from there). Only happened once, but manual backup in a different location can solve this issue also. Use GIMP if you want BMP instead of PNG btw. Comparisons for me show BMP is more useful and communicative with GMS (1.4).
c. JPEXS Flash Decompiler
d. SWFTOOLS (I am using Windows 7 64bit OS) with 32bit exe's for the programs due to GMS nature of *32 locations and install. It includes the needed png2swf.exe and more.
swftoolslocationafterinstall.PNG
e. swf_output.INX file for Inkscape extensions and pdf2swf batch file unless you dont have windows, then the sh script in the link below works, otherwise get it from user naddercrusher, which I had to do. A link to his thread creation is here: https://www.reddit.com/r/gamemaker/comments/6gwq4c/swf_exporter_for_inkscape_windows_version/

NOTE: link for SWFTOOLS is here: http://technoargia.free.fr/swftools/ (for now anyway).​

I believe that is all for now.

SETUP:
  • Download the necessary programs and files above. For caution, always install with admin permissions!
  • Check the programs to make sure they are not blocked in the settings, and if so, unblock them. May not be necessary, but just in case.
  • blockedfileloc.PNG
  • Start each program and exit them to make sure all files and setups are loaded for them individually. Some programs create folders only after they are ran for the first time.
  • For Inkscape, open a folder under your extensions library, which for me is located in C:\Program Files\Inkscape\share\extensions.
  • Put the swf_output.INX and the pdf2swf.bat (or .sh for linux, etc) in there.

  • reopen Inkscape and you "should" see an export option toward the bottom that says Flash SWF.
inkscapeswfexport.PNG

  • I am using Inkscape 0.92.2 latest atm. If that does not show up, re-follow the steps in the link in step e. again.
Once you have flash swf export available for Inkscape, that is a big step because it has been written to work with GMS with a few needed changes from the decompiler.

Create an svg file with shapes to test. save as svg first! Then export swf and get the options up for that. Here are mine.
swfexportoptions.PNG stars vector in inkscape.PNG blockedfileloc.PNG swftoolslocationafterinstall.PNG inkscapeswfexport.PNG swfexportoptions.PNG stars vector in inkscape.PNG blockedfileloc.PNG swftoolslocationafterinstall.PNG inkscapeswfexport.PNG swfexportoptions.PNG
THis works for me, and text Ill explain soon (its different).
after export it will open a cmd and ask to name it again. NAME IT SOMETHING DIFFERENT or it will overwrite the base swf needed for pdf2swf to work.

In GMS, create an object and new sprite and load sprite and find the swf that was LAST created, not the initial swf export one, but the very last step of export and click on that. It should load the swf and say some errors either about incompatability or the program not being able to show image correctly unless in game etc. Click ok for all of that.

See if the vector shows up.

Now....you can do this in between for other options:
for better compatability (at least from what I found out after days and days of comparisons and errors), open the swf that you want to import to GMS in the decompiler. Now, in here there are only a few things you want to do.

1. Get rid of that black background crap.....
2. Make the swf decompressed and disable any scripts in the swf that ask for actionscript actions like at the bottom it might say something about stopping the animation etc. Thats actionscript and we dont want that because GMS hates it. Getting rid of the backgrounds also will make the file smaller and also just get rid of unnecessary image compilations in the swf.
3. Change the frames from whatever it says (default I think it says 0.25) to 1. Save it and close the decompiler BEFORE loading back into GMS (or initially if you decide to do this before importing anyway).


You might see that the vector is showing up with transparency, or you might see a white image, etc but in game, it will look right if you did everything right!

After the sprite is all set and proper, You need to enable the swf GML commands. I just created a script and ran it during the initialize room creation once. Those scripts are:
Code:
draw_enable_swf_aa(true);
draw_set_swf_aa_level(1); //0 - 1 is the scale where 1 is full antialias
draw_get_swf_aa_level();
This can all go in a script and ran at the beginning of the game (even before the main menu as far as I have tested);
So anything that is swf, will use this and look better.

For text, you can still use text from Inkscape, BUT few steps before it looks right in vector:
1. Change text to Path/Object to Path.
2. ungroup everything text
3. select one text field at a time, or one path at a time, and go to Path/Break Apart to get the inside of the texts to show up (since they are ninjas by default).
4. with the same text selected, go to Path/Division (can only have 2 paths selected or it will erase everything but one path. Otherwise we want to only get rid of the fill inside the texts WHICH...are what shows up in the vector if we dont do this!
5. deselect everything and select only the inside of letters that filled up and delete them all!
6. Then you can export as usual, and the letters should show up normal in GMS when you get to the import of swf from the sprite window.


I typed this in about 20 minutes just to get this out there but feel free to ask me questions. Ill try to help best I can but keep in mind, I am on Windows 7 64bit OS and also went through GIMP process (worked also) but GIMP glitched on me and was bad joojoo so own risk on that program route, I cant help there.

I found that using vectors for background (using stretched sprites and such) is the most beneficial reason for this, but also, text looks crisper to me and if you plan to scale, its a lifesaver if you have everything else set up properly! Vectors for fast moving object and small object (usually smaller than 128 x 128) are not really needed as much because BMP does a great job keeping up if you have the proper game graphic settings.

Other than that, Im tired and I need to sleep now. Been working on this for weeks! Now I have to redo my entire game, but at least my formatting and process will be clean with newer and cleaner sprites and visuals!

Not recommended to do this mid process or after development as it can change everything!
Drawing the sprites and scaling them UP is much more useful also, than downscale etc. If you have to downscale, might as well use BMP (I not say PNG because of some testing I did on objects with both formats, finding bmp is still highly useful).
 
J

jason_Evans

Guest
Here is a different game main title page I am working on with ALL VECTORS!
 
J

jason_Evans

Guest
Just in case anyone has wondered or questioned the use of SWF files......here is my new game so far...created yesterday when this was originally posted and this is how far I have got. EVERYTHING with the exception of the resolution showing at the bottom of the options page is vectored swf. Anyone worried about quality may not have to do so anymore. There are limits, obvisouly, but the only one I have found so far is an asset compile error if anything is circle gradient (working on path files in xml to fix if possible). Also, the created sprites are each only 1kb! This will be my last post on this thread unless others become interested. But I think this is something worthy of checking out....at least for menus and such for any game. Any thoughts? Here it is:


 
Top