sprite.alpha
Category:Sprites
This property changes the transparency of a sprite. You can assign it decimal values between 0 and 1.
Examples
Ghost Cow
Creates three cows, one of which is transparent using the alpha block
var red_cow = createSprite(100, 200);
red_cow.setAnimation("cow");
red_cow.tint = "red";
var blue_cow = createSprite(200, 200);
blue_cow.setAnimation("cow");
blue_cow.tint = "#0000FF";
var ghost_cow = createSprite(300, 200);
ghost_cow.setAnimation("cow");
ghost_cow.alpha = 0.5;
drawSprites();

Syntax
sprite.alpha = 0.5
Tips
- Sprites all have the same properties and you use the dot notation (combining the name of the sprite, followed by a dot, with the label of the property) to both access and update the property for that sprite.
- Any changes to the properties of a sprite will not be seen until after
drawSprites()
is called.
Found a bug in the documentation? Let us know at support@code.org.