Sounds in the Pinball Games iOS and tvOS Starter Kit
The Sounds dictionary inside your table dictionary has properties for some of the more common place sounds. What is listed here is just the tip of the iceberg in terms of what can be heard from the app. Any TableObject, Light or Goal can trigger a single sound or random sound (even multiple sounds in sequence too).
Every property that lists sounds to play, except the MP3Loop property, can be randomized. To randomize sounds, simply switch the value type from String to Array. Notice in the image above, the BallHitBall property is an array, and when unfolded shows two String properties of ballhitball.caf and ballhitball2.caf (.caf is Apple’s preferred sound format for short clips). At runtime the app will randomly pick one of these two sounds to play. Your Array can list as many sounds as you want. Including duplicates if you want to favor one sound randomly being picked over another. File types can be either .caf, .mp3 or other audio formats that Sprite Kit supports.
The MP3Loop property will loop an audio track until the current table scene is closed. This property value should be equal to an mp3 file imported to the kit. This property, unlike all the others, requires an mp3 file.
Below we will describe each sound property that can be set to a String value (single value) or Array of Strings (to randomize which sound will play). All of these are optional, but we have included many sounds with the kit that you can use.
- IntroSounds – this sound file will play when the app first loads the table. This could be an intro “sting”, a like quick bit of music possibly.
- IntroMessage – this sound file will also play when the app first loads, but it is delayed by 2 seconds (or a number set using the IntroMessageDelay property). This might be a vocal clip, someone saying “New Game”. But it can be anything.
- FlipperRight – this sound file will play when the right flippers are used
- FlipperLeft – this sound file will play when the left flippers are used
- PlungerEnter – this sound file will play when the ball enters the plunger (like after a ball loss)
- PlungerLaunch – this sound file will play when the ball is launched
- BallRollFromPlunger – this sound will also play when the ball is launched. It might be a longer than usual ball rolling sound.
- BallRoll – this is a particularly good property to set as an array. We think it is important to include many different ball rolling sounds. The sounds in this Array can be triggered to play by any TableObject or Light after contact is made.
- BallHitBall – this sound will play when the ball hits another ball.
- BallOnRail – this sound will play when the ball begins rolling on a rail (any seemingly raised ramp)
- LostBall – this sound will play anytime the ball goes into the drain and the player loses one of their remaining balls. This sound is not played when all their balls are gone.
- BallOffTable – this sound is played if the ball goes below the point where it would normally be lost, but the ball’s x location is less than zero and greater than the scene width (implying the ball escaped the table somehow).
- GameOver – this sound file is played when the game is over.
- Tilt – this sound is played if the user tilts the table to move a stuck ball. (Tilting is done by tapping with two fingers, or if using a Game Controller by hitting the Y button)