Sprite::playSound()
Plays a sound.
Examples

import org.openpatch.scratch.*;
public class SpritePlaySound {
public SpritePlaySound() {
Stage myStage = new Stage(254, 100);
Sprite zeta = new Sprite("green", "assets/zeta_green_badge.png");
zeta.addSound("bump", "assets/bump.wav");
myStage.add(zeta);
while (myStage.getTimer().forMillis(3000)) {
zeta.playSound("bump");
myStage.wait(500);
}
Window.getInstance().exit();
}
public static void main(String[] args) {
new SpritePlaySound();
}
}
Syntax
Java
.playSound(name)
Scratch
Parameters
Name | Data Type | Description |
---|---|---|
name | String | The name of the sound to play |
Return
void