Sprite::addCostume()
Add a costume to the sprite. The costume can either be an image or a part of a spritesheet.
Examples
import org.openpatch.scratch.*;
public class SpriteAddCostume {
public SpriteAddCostume() {
Stage myStage = new Stage(600, 240);
Sprite zeta = new Sprite("green", "assets/zeta_green_badge.png");
zeta.addCostume("yellow", "assets/zeta_yellow_badge.png");
myStage.add(zeta);
myStage.wait(1000);
myStage.exit();
}
public static void main(String[] args) {
new SpriteAddCostume();
}
}
Syntax
Java
.addCostume(name, filePath)
.addCostume(name, filePath, x, y, width, height)
Scratch
Parameters
Name | Data Type | Description |
---|---|---|
name | String | Name of the costume |
filePath | String | Path to an image file. |
x | int | x-Coordinate in a Spritesheet. |
y | int | y-Coordinate in a Spritesheet. |
width | int | Width of the image at the x- and y-coordinate in the Spritesheet. |
height | int | Height of the image at the x- and y-coordinate in the Spritesheet. |
Return
void