Goal:
Now our lightsaber can turn on and off, but we want to add some sound effects to it while it’s on.
When you swing a lightsaber it makes noise, so we want to add some sound files to our app that activate when we swing our phone.
We are going to use a random picker so that our swing sounds are different and isn’t just the same sound played over and over again.
Steps:
- From AccelerometerSensor, place a Shaking block on the screen.
- From Control, place an IF/THEN block inside of the Shaking block.
- From Variables, attach a get block to the IF portion of the IF/THEN and set it to saberOn.
- From SaberSwing1, place a set SaberSwing1.Source to block inside of the THEN portion of the IF/THEN block.
- From List, attach a pick a random item list block to the SaberSwing1.Source block.
- From List, attach a make a list block to the end of the pick a random item list block.
- From Text, place an empty text box block in each of the make a list slots.
- Type “SaberSwing1.wav” into the first one.
- Type “SaberSwing2.wav” into the second one.
- From SaberSwing1, place a Play block.
- From SaberSwing1, place a Vibrate millisecs block.
- From Math, attach a 0(zero) block to the end of the Vibrate millisecs block.