Background music can create atmosphere in your games. This tutorial shows how to add background music and how to make it loop.
- [Instructor] When you want to load background music,…it actually works a little bit different…from loading a sound effect.…So I have my music file here,…which is a loop called music.m4a.…I just made it in GarageBand.…So here I am in didMove to view in my code,…and instead of creating an action,…background music allows looping and uses a node…so I'm going to define my background sound effect…and that's going to be an SKAudioNode.…So I'll instantiate it to an SKAudioNode…and I'm going to use the constructor…that asks for file name and receives a string.…
The file's going to be music.m4a…and then I'm going to go to the next line…and then we actually need to add it to the stage…so I'll call self, addChild…and then I'll pass in bg.…So just like any other node,…we need to add the audio as well.…Now if you want it to loop,…then you can add an extra line right below…where we declared it to set its…autoplayLooped property equal to true.…
So we do that, then the sound file should loop.…Let's run the application and see how it goes.…
- Creating a SpriteKit project
- Adding and modifying sprites
- Creating sprites in code
- Transitioning between scenes
- Working with children and parents
- Adding physics
- Detecting and responding to collisions
- Applying particle effects
- Creating actions
- Working with sound
- Adding cameras and lights
Skill Level Intermediate
Game Design Careers with Brenda Romerowith Brenda Romero54m 41s Beginner
Careers in the Game Industrywith Christian Bradley1h 19m Beginner
Building a Game App with the Android SDKwith David Gassner2h 6m Intermediate
1. Introduction to SpriteKit
2. Add Physics
3. Work with Particle Effects
4. Work with Actions
5. Work with Audio
6. Additional Features
Next steps1m 41s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.