Sprite::switchCostume()
Changes the sprite's costume to the specified one.
Examples
import org.openpatch.scratch.Sprite;
import org.openpatch.scratch.Stage;
public class SpriteSwitchCostume {
public SpriteSwitchCostume() {
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(3000);
zeta.switchCostume("yellow");
myStage.wait(3000);
myStage.exit();
}
public static void main(String[] args) {
new SpriteSwitchCostume();
}
}
Syntax
Java
.switchCostume(name)
.switchCostume(index)
Scratch
Parameters
Name | Data Type | Description |
---|---|---|
name | String | Name of the costume. |
index | int | Index of the costume. |
Return
void