Exemplo n.º 1
0
        /// <summary>
        /// Load a music file from a filename. Adds to a dict to keep loaded sounds cached.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static Sound LoadFromFile(string path)
        {
            Initialise();
            if (_audios.ContainsKey(path))
            {
                return _audios[path];
            }

            if (!File.Exists(path)) return null;
            int handle = Bass.BASS_StreamCreateFile(path, 0, 0,
                BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_STREAM_PRESCAN);
            handle = BassFx.BASS_FX_TempoCreate(handle, BASSFlag.BASS_MUSIC_PRESCAN);

            if (handle == 0)
            {
                return null;
            }

            try
            {
                var audio = new Sound(handle, path);
                _audios.Add(path, audio);
                return audio;
            }
            catch (Exception ex)
            {
                Out.Red(ex.Message);
            }
            return null;
        }
Exemplo n.º 2
0
        public override void OnLoad(EventArgs args)
        {
            base.OnLoad(args);

            Camera = new Camera();

            _bg = new Image(new PointF(0, 0), new SizeF(1024, 768), "assets/gfx/background/menubg.png")
            {
                Camera = Camera
            };

            _biscuitText = new Text(size =>
                                new PointF((1024f / 2f) - (size.Width / 2f), (768f / 2f) - (size.Height / 2f)),
                                                         string.Format("Biscuit Dev Build {0}", _game.Version),
                                                                            shadow: true, colour: Color4.White)
            {
                Camera = Camera
            };

            _startText = new Text(size =>
                                new PointF((1024f / 2f) - (size.Width / 2f),
                                     (768f / 2f) - (size.Height / 2f) + 50),
                                                    "Press escape to begin",
                                shadow: true, colour: Color4.Orange) {Camera = Camera};

            _menuMusic = AudioManager.LoadFromFile(Resources.MENU_MUSIC);
            _menuMusic.Play(true, true);
        }
Exemplo n.º 3
0
 public void SetMusic(Sound music)
 {
     _music = music;
 }