IMD1 _ Add background music and sound effect

This time, we will going to add background music and collision sound effect.

Find the bgm and collision sound and drag them into the your project name folder.

Then you’ll see this screen. Just click finish.

스크린샷 2016-05-31 오전 11.23.19.png

Change the name ‘explosion’, ‘bgMusic’.

스크린샷 2016-05-31 오전 11.25.19.png

Go to GameScene.swift, and let’s add some code. We will  import library for audio and video.

스크린샷 2016-05-31 오전 11.30.15.png

And we will create variable for our audio files.

스크린샷 2016-05-31 오전 11.32.27.png

We will set up the audio player and create the path to the audio files.

스크린샷 2016-05-31 오전 11.48.26.png

And we associate the audio variables with their files.

스크린샷 2016-05-31 오후 12.02.06.png

If your music sound is too big, you can change the volume. Mine was okay.

스크린샷 2016-05-31 오후 12.15.48.png

Now we will add collision sound. If the hero get hit, the bgm will stop and only collsion sound will play, and after the countdown the bgm will start again.

스크린샷 2016-05-31 오후 12.17.47.png

스크린샷 2016-05-31 오후 12.18.15.png

And you can also change background color.

스크린샷 2016-05-31 오후 12.25.14.png

스크린샷 2016-05-31 오후 12.25.07.png

스크린샷 2016-05-31 오후 12.26.18.png

And in badguy.swift, we can change the angle or range of motion.

스크린샷 2016-05-31 오후 12.34.40.png

Speed also! These function will going to decide your game’s difficulty.

스크린샷 2016-05-31 오후 12.39.44.png

And I downloaded countdown sound effect. I tried to add a countdown effect. The sound was played well, but didn’t stopped when the game restart. I have to add some code about stop the sound when the game begins.

스크린샷 2016-06-05 오후 3.42.10.png

스크린샷 2016-06-05 오후 3.42.24.png

스크린샷 2016-06-05 오후 3.43.03.png

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s