draw_set_alpha


描述

With this function you can set the base draw alpha for the game. This value can be set from 0 to 1 with 0 being fully transparent and 1 being fully opaque (the default value), and will affect all further drawing, including backgrounds, sprites, fonts, primitives and 3D.

Note that if you are drawing any of the assets and supplying an alpha argument as part of the function (for example, when using draw_sprite_ext()), then the alpha value set here will be overridden, so drawing a sprite using draw_sprite_ext with an alpha argument of 1 will draw the sprite fully opaque regardless of the alpha set with draw_set_alpha (this will work the same when using draw_self() and setting the image_alpha of the instance). Also note that when an instance is default drawing (ie: it has a sprite but no Draw Event), then the image_alpha variable will be clamped to the alpha set with draw_set_alpha(), such that an image_alpha of 1 and a draw alpha of 0.5 will draw the sprite at alpha 0.5, while an image_alpha of 0.25 and a draw alpha of 0.5 will draw the sprite at 0.25 alpha.


语法:

draw_set_alpha(alpha);


参数 描述
alpha The alpha to set (between 0 and 1)


返回:

N/A(无返回值)


例如:

draw_set_alpha(0.5);
draw_set_colour(c_black);
draw_text(x+5, y+5, "LEVEL 1");
draw_set_alpha(1);
draw_set_colour(c_white);
draw_text(x, y, "LEVEL 1");

The above code will draw some text at the specified position with a shadow effect created by modified draw alpha and colour.