layer_sprite_get_alpha


Description

This function can be used to get the alpha value of the sprite element. You give the sprite element ID (which you get when you create a sprite element using layer_sprite_create() or when you use the function layer_sprite_get_id()), and the function will return a value between 0 (fully transparent) and 1 (fully opaque).


Syntax:

layer_sprite_get_alpha(sprite_element_id);


Arguments:

Argument Description
sprite_element_id The unique ID value of the sprite element to get the information from


Returns:

Real (from 0 to 1)


Example:

var lay_id = layer_get_id("sprite_sky");
var spr_id = layer_sprite_get_id(lay_id, "Clouds");
if layer_sprite_get_alpha(spr_id) < 0.1
   {
   layer_sprite_destroy(spr_id);
   }

The above code will get the layer ID for the layer named "sprite_sky" and then use that to get the ID of the sprite element on that layer. This ID is then used to check the element alpha and if it is less than 0.1, then the layer element is destroyed.


Back: Sprite Layer Functions
next: layer_sprite_get_x
© Copyright YoYo Games Ltd. 2018 All Rights Reserved