⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 music.cs

📁 Introduction to 3d game engine design一书的源代码!
💻 CS
字号:
using System;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.AudioVideoPlayback;

namespace GameEngine
{
	/// <summary>
	/// Summary description for Music.
	/// </summary>
	public class Music : Microsoft.DirectX.AudioVideoPlayback.Audio
	{
		#region Attributes
		private bool  loop = false;
		#endregion

		#region Properties
		public bool  Loop { get { return loop; } set { loop = value; } }
		public float MusicVolume { set { base.Volume = (int)(-4000 * (1.0f - value)); } }
		#endregion

		/// <summary>
		/// Music constructor
		/// </summary>
		public Music( string filename ) : base(filename)
		{
			try
			{
				Ending += new System.EventHandler(this.ClipEnded);
			}
			catch (DirectXException d3de)
			{
				Console.AddLine("Unable to create music ");
				Console.AddLine(d3de.ErrorString);
			}
			catch ( Exception e )
			{
				Console.AddLine("Unable to create music ");
				Console.AddLine(e.Message);
			}
		}

		private void ClipEnded(object sender, System.EventArgs e)
		{
			// The clip has ended, stop and restart it
			if ( loop )
			{
				Stop();
				Play();
			}
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -