Update on-event.md (#1718)

Explain what "background melody" means
This commit is contained in:
Niels 2019-01-04 00:57:55 +01:00 committed by Peli de Halleux
parent 79b47fb62a
commit 7856c046f4

View File

@ -49,3 +49,17 @@ input.onButtonPressed(Button.A, () => {
music.setTempo(100)
music.beginMelody(music.builtInMelody(Melodies.Ringtone), MelodyOptions.ForeverInBackground)
```
## Background melody
The events related to background melody get triggered by a melody that is played inside a run in background block.
```
control.inBackground(function () {
basic.pause(Math.randomRange(0, 5000))
music.beginMelody(music.builtInMelody(Melodies.Entertainer), MelodyOptions.Once)
})
music.onEvent(MusicEvent.BackgroundMelodyStarted, function () {
basic.showIcon(IconNames.EigthNote)
})
```