In this recipe we are going to illustrate how to add background music to your game.
Load up PlayStation Mobile Studio and create a new project. Add a reference to Sce.PlayStation.GameEngine2D
. This example also requires a pair of MP3 files; I used two public domain classical music scores. The complete source for this example can be found in Ch4_Example6
.
Add the two MP3 files to your project; set their Build Action to Content.
Open
AppMain.cs
and replace the existing code with the following code:using System; using System.Collections.Generic; using Sce.PlayStation.Core; using Sce.PlayStation.Core.Environment; using Sce.PlayStation.Core.Graphics; using Sce.PlayStation.Core.Input; using Sce.PlayStation.Core.Audio; using Sce.PlayStation.HighLevel.GameEngine2D; namespace Ch4_Example6 { public class AppMain{ private static Dictionary<string,Bgm> _songs; private static BgmPlayer _bgmPlayer; private static void PlaySong...