本文整理汇总了C#中Microsoft.Xna.Framework.Audio.SoundEffect.Play方法的典型用法代码示例。如果您正苦于以下问题:C# SoundEffect.Play方法的具体用法?C# SoundEffect.Play怎么用?C# SoundEffect.Play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Audio.SoundEffect
的用法示例。
在下文中一共展示了SoundEffect.Play方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ship
public Ship(Game game, Vector2 PosicaoInicial, Texture2D texture, SoundEffect SoundShip)
: base(game, PosicaoInicial, texture)
{
_game = game;
ShipSound = SoundShip;
ShipSound.Play();
SpriteX = 0;
SpriteY = 0;
PosicaoX = (int)PosicaoInicial.X;
PosicaoY = (int)PosicaoInicial.Y;
Vida = 100;
accelReading = new Vector3();
accelSensor = new Accelerometer();
accelSensor.ReadingChanged +=
new EventHandler<AccelerometerReadingEventArgs>(AccelerometerReadingChanged);
try
{
accelSensor.Start();
accelActive = true;
}
catch (AccelerometerFailedException e)
{
accelActive = false;
}
catch (UnauthorizedAccessException e)
{
accelActive = false;
}
}
示例2: Explosion2
/// <summary>
/// Creates a new explosion
/// </summary>
/// <param name="position">The position of the explosion within the game world</param>
/// <param name="content">A ContentManager to load resources with</param>
public Explosion2(uint id, Vector2 position, ContentManager content, float scale)
: base(id)
{
this.position = position;
Scale = scale;
this.spriteSheet = content.Load<Texture2D>("Spritesheets/explosion");
explosionSound = content.Load<SoundEffect>("SFX/Blast");
explosionSound.Play();
for (int i = 0; i < 12; i++)
{
spriteBounds[0] = new Rectangle(134 * i, 0, 134, 134);
}
spriteBounds[0] = new Rectangle(0, 0, 134, 134);
spriteBounds[1] = new Rectangle(134, 0, 134, 134);
spriteBounds[2] = new Rectangle(268, 0, 134, 134);
spriteBounds[3] = new Rectangle(402, 0, 134, 134);
spriteBounds[4] = new Rectangle(536, 0, 134, 134);
spriteBounds[5] = new Rectangle(670, 0, 134, 134);
spriteBounds[6] = new Rectangle(804, 0, 134, 134);
spriteBounds[7] = new Rectangle(938, 0, 134, 134);
spriteBounds[8] = new Rectangle(1072, 0, 134, 134);
spriteBounds[9] = new Rectangle(1206, 0, 134, 134);
spriteBounds[10] = new Rectangle(1340, 0, 134, 134);
spriteBounds[11] = new Rectangle(1474, 0, 134, 134);
this.explosionState = 0;
this.explosionTimer = 0;
}
示例3: PlayRecordedAudio
private void PlayRecordedAudio()
{
SoundEffect se = new SoundEffect(audio.ToArray(), mic.SampleRate,
AudioChannels.Stereo);
se.Play(1.0f, -1.0f, 0.0f);
btnRecord.IsEnabled = true;
}
示例4: playSound
public static void playSound(string soundName, float volume)
{
effect = m_Content.Load<SoundEffect>(soundName);
if (m_EffectInstance == null)
{
m_EffectInstance = effect.CreateInstance();
effect.Play(volume, 0, 0);
}
else
{
effect.Play(volume,0,0);
}
m_EffectInstance = null;
}
示例5: Play
/// <summary>
/// Plays a given song as the background music.
/// </summary>
/// <param name="song">The song to play.</param>
public void Play(SoundEffect sound, float volume)
{
if (IsMuted)
return;
volume = Math.Min(volume, MaxVolume);
sound.Play(volume, 0.0f, 0.0f);
}
示例6: Initialize
public void Initialize(Animation anim, int timeOflife, SoundEffect sound)
{
this.EffectAnimation = anim;
this.TimeOfLiving = timeOflife;
VisualEffectSound = sound;
Alive = true;
if (VisualEffectSound != null) VisualEffectSound.Play();
}
示例7: Collect
public void Collect(Rectangle loc, Level level, SoundEffect pearSound)
{
if (loc.Intersects (location) && !collected) {
level.numCollected++;
pearSound.Play ();
collected = true;
}
}
示例8: listenAgainHold
private void listenAgainHold(object sender, System.Windows.Input.GestureEventArgs e)
{
Thread.Sleep(1500);
Microphone mic = Microphone.Default;
SoundEffect soundEffect = new SoundEffect(myMicrophone.streamMicrophone.ToArray(), mic.SampleRate, AudioChannels.Mono);
myMicrophone.streamMicrophone.Seek(0, System.IO.SeekOrigin.Begin);
soundEffect.Play(1.0f, 0.0f, 0.0f);
}
示例9: PlaySound
/// <summary>
/// Plays specified sound at specified place. It automaticly sets the volume.
/// </summary>
/// <param name="sound">The specified sound</param>
/// <param name="position">The specified position</param>
public void PlaySound(SoundEffect sound, PositionInTown position)
{
if (game.Player.Position.Quarter == position.Quarter)
{
float quarterDiagonalLength = (new Vector2(position.Quarter.BitmapSize.Width, position.Quarter.BitmapSize.Height) * TownQuarter.SquareWidth).Length();
sound.Play(1f- (position.MinimalDistanceTo(game.Player.Position) / quarterDiagonalLength), 0f, 0f);
}
}
示例10: playEffect
public void playEffect(String soundname, ContentManager content, bool sound)
{
if (sound == true)
{
effect = content.Load<SoundEffect>(soundname);
effect.Play();
}
}
示例11: Explosion
public Explosion(Rectangle box) :
base (Globals.Content.Load<Texture2D>("Textures/explosion.png"), box)
{
time = 200;
ExplosionList.Add(this);
sound = Globals.Content.Load<SoundEffect>("Sounds/explosion.wav");
sound.Play();
}
示例12: Play
//TODO: play on gsm output device
public void Play(byte[] packetData)
{
lock (SyncObj)
{
_soundEffect = new SoundEffect(packetData, _microphone.SampleRate, AudioChannels.Mono);
_soundEffect.Play();
//_soundEffect.Dispose();
}
}
示例13: Explosion
/// <summary>
/// Constructs a new explosion object
/// </summary>
/// <param name="spriteStrip">the sprite strip for the explosion</param>
/// <param name="x">the x location of the center of the explosion</param>
/// <param name="y">the y location of the center of the explosion</param>
public Explosion(Texture2D spriteStrip, int x, int y, SoundEffect explosion)
{
// initialize animation to start at frame 0
currentFrame = 0;
Initialize(spriteStrip);
Play(x, y);
explosion.Play();
}
示例14: LoadContent
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
soundEffect = Content.Load<SoundEffect>("Audio/start");
soundEffect.Play();
}
示例15: handleCollision
public void handleCollision(Vector2 collisionVect, SoundEffect playSound)
{
if (collisionCD <= 0)
{
mVelocity = collisionVect;
collisionCD = 60;
playSound.Play();
mEffect.init();
}
}