Scratch for Java

Sprite::setTransparency()

Sets the sprite's transparency to the percentage.

Examples

import org.openpatch.scratch.Sprite;
import org.openpatch.scratch.Stage;
 
public class SpriteSetTransparency {
  public SpriteSetTransparency() {
    Stage myStage = new Stage(600, 240);
    Sprite mySprite = new Sprite("slime", "assets/slime.png");
    myStage.add(mySprite);
    myStage.wait(2000);
    mySprite.setTransparency(50);
    myStage.wait(2000);
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new SpriteSetTransparency();
  }
}
 

View on GitHub

Syntax

Java

.setTransparency(percentage)

Scratch

set [ghost v] effect to (50)

Parameters

Name Data Type Description
percentage float A value in percent in the range of 0 ... 255.

Return

void

setTransparency()