This variable is used to get or to set the alpha value for the sprite. Alpha is always calculated as a value between 0 and 1 where 0 is completely transparent and 1 is completely opaque. Please note that for changes in this variable to be visible, the instance should have either no draw event (and so GameMaker Studio 2 will default draw the sprite) or be drawn using one of the extended drawing functions like draw_self() or draw_sprite_ext().

NOTE: On the HTML5 platform, this variable is not clamped. Therefore if you have a value greater than one, it will "wrap" back to 0 again, giving flickering results. Likewise if you go below 0, the alpha will "wrap" back to 1. You can use the function clamp for this.




Real (between 0 and 1)


image_alpha = clamp(image_alpha - 0.01, 0, 1);

The above code will slowly reduce the image_alpha until it reaches 0.