• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

SWF Sprites Don't Use Masks on GUI Layer

SWFMan

Member
Hi, I'm porting a project over from GMS 1.4 into GMS 2 and things have generally been going smoothly.

One annoyance that I can't seem to find any existing mention of is that any of my SWF sprites that draw to the GUI aren't holding their masks in properly. This wasn't an issue in GMS 1 and this isn't an issue when drawn in a normal Draw event.

HP.png

As you can see, the HP bar is flying way off past its limit. The quality is lousy in that picture because I just set up a new project and I haven't used any of the setup codes for .swf quality.

There's nothing special in the draw events. This new project just has two objects with a draw_self(); and draw_sprite(Sprite1, -1, 500, 500);, but the GUI one draws without a proper mask.

I believe this is a bug, but I'm holding out for some saviour to tell me that there's some kind of draw_gui_mask_enable magic line of code that will fix my game's UI. I've tried re-exporting and re-importing the .swfs in different versions but to no avail.

BONUS: The "HP" text is also supposed to match the colour of the bar. It seems anything that's been tinted in Flash/Animate with the "tint" feature (which apparently includes coloured text) has its RGB values messed with. This also was not an issue when using .swfs in GameMaker 1. Anyone have any thoughts on how to fix that?
 

SWFMan

Member
For anyone that ends up in this extremely specific situation in the future: I did find a solution, just a tedious one.

Since the .swfs were drawing normally in a Draw event, I moved the Draw GUI code into a Draw event and drew it to a surface. Then, I drew that surface in the Draw GUI event. This means it technically loses its "lossless" properties as a vector sprite, but at the same time, since it's making a sprite the exact size of the screen every frame, it actually doesn't matter. This didn't make my FPS dip below 60, either, and I have a pretty big project.

So, I have to add a Draw event with:

if(!surface_exists(surface)){
surface = surface_create(1920,1080);
}
surface_set_target(surface);
//original draw GUI goes here
surface_reset_target();

Then, in the Draw GUI where the code was:
draw_surface(surface,0,0);

And the Create event needs a surface = -1; to initialize it, and the Destroy event needs a surface_free(surface); to prevent a leak.

It'll be tedious going through every single Draw GUI event to make these changes, but hey, any solution seems like a godsend at this point. I didn't solve the tinting issue, but there are so few examples in my game that I can just re-export the files without tints. Here's hoping GMS2 gets updated to read vector sprites as cleanly as GMS1 did!
 
Last edited:
Top