Sprite::addCostume()
Add one of the costumes that ship with Scratch for Java to the sprite. The costume gets the same name as the built-in sprite. If a costume with that name already exists do nothing.
Example usage:
this.addCostume("bunny1_jump");
Examples
Syntax
Java
.addCostume(name)
.addCostume(name, imagePath)
.addCostume(name, spriteSheetPath, x, y, width, height)
Parameters
| Name | Data Type | Description |
|---|---|---|
| name | String | the name of a built-in sprite, for example "bunny1_jump". Add the sheet in front of the name, for example "platformer/grass", if the same name exists on several sheets. |
| imagePath | String | a image path, or the name of a built-in sprite such as "bunny1_jump" |
| spriteSheetPath | String | The path to the sprite sheet image file. |
| x | int | The x-coordinate of the top-left corner of the costume in the sprite sheet. |
| y | int | The y-coordinate of the top-left corner of the costume in the sprite sheet. |
| width | int | The width of the costume in the sprite sheet. |
| height | int | The height of the costume in the sprite sheet. |
Return
void