本文整理汇总了C#中Microsoft.Xna.Framework.Audio.SoundEffectInstance.Apply3D方法的典型用法代码示例。如果您正苦于以下问题:C# SoundEffectInstance.Apply3D方法的具体用法?C# SoundEffectInstance.Apply3D怎么用?C# SoundEffectInstance.Apply3D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Audio.SoundEffectInstance
的用法示例。
在下文中一共展示了SoundEffectInstance.Apply3D方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShipObj
public ShipObj(MobileFortressClient game,Vector3 position, Quaternion orientation, ShipData data)
: base(game,position,orientation,2)
{
Data = data;
Data.ComposeHitbox();
Data.Hitbox.Position = position;
Sector.Redria.Space.Add(Data.Hitbox);
this.Entity = Data.Hitbox;
//Thrusters = new SingleEntityLinearMotor(Entity, Position);
//ControlSurfaces = new SingleEntityAngularMotor(Entity);
//ControlSurfaces.Settings.Mode = MotorMode.Servomechanism;
//ControlSurfaces.Settings.Servo.MaxCorrectiveVelocity = 2;
//Thrusters.Settings.Mode = MotorMode.VelocityMotor;
//Thrusters.Settings.VelocityMotor.Softness = 0.002f;
//Sector.Redria.Space.Add(Thrusters);
//Sector.Redria.Space.Add(ControlSurfaces);
Entity.IsAffectedByGravity = false;
engineNoise = Resources.Sounds.Engine.CreateInstance();
engineNoise.Apply3D(Camera.Audio, Audio);
engineNoise.IsLooped = true;
engineNoise.Play();
Entity.CollisionInformation.Tag = this;
}
示例2: Rocket
public Rocket(MobileFortressClient game, ushort resource, Vector3 position, Quaternion orientation)
: base(game, resource, position, orientation)
{
rocketEngineSound = Resources.Sounds.RocketEngine.CreateInstance();
UpdateAudio();
SoundEffectInstance rocketNoise = Resources.Sounds.WeaponSounds[3].CreateInstance();
rocketNoise.Apply3D(Camera.Audio,Audio);
rocketNoise.Play();
rocketEngineSound.IsLooped = true;
rocketEngineSound.Apply3D(Camera.Audio, Audio);
rocketEngineSound.Play();
}
示例3: LoadContent
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
soundEffect = this.Content.Load<SoundEffect>("circus");
instance = soundEffect.CreateInstance();
instance.IsLooped = true;
listener = new AudioListener();
emitter = new AudioEmitter();
// WARNING!!!! Apply3D requires sound effect be Mono! Stereo will throw exception
instance.Apply3D(listener, emitter);
instance.Play();
}
示例4: Apply3DAudio
/// <summary>
/// Helps apply the distance effect of our music and enemy foot step
/// </summary>
/// <param name="listener">The listener of the sound and music</param>
/// <param name="location">The location that emits the sound and music</param>
/// <param name="music"></param>
public void Apply3DAudio(AudioListener listener, Vector3 location, SoundEffectInstance music)
{
AudioEmitter emitter = new AudioEmitter();
emitter.Position = location;
emitter.Up = Vector3.Up;
emitter.Velocity = location - position;
emitter.Forward = Vector3.Normalize(location - position);
music.Apply3D(listener, emitter);
if ( leftLegRotation < MIN_LEG_ROTATION || rightLegRotation < MIN_LEG_ROTATION )
{
// switch between left and right foot step sound
if (isLeftLegForward)
{
SoundEffectInstance sfxInstance = leftFootStepAudio.CreateInstance();
sfxInstance.IsLooped = false;
sfxInstance.Apply3D(listener, emitter);
sfxInstance.Play();
}
else
{
SoundEffectInstance sfxInstance = rightFootStepAudio.CreateInstance();
sfxInstance.IsLooped = false;
sfxInstance.Apply3D(listener, emitter);
sfxInstance.Play();
}
// Switch legs
isLeftLegForward = !isLeftLegForward;
}
}
示例5: Update3DSoundEffect
/// <summary>
///
/// </summary>
/// <param name="se"></param>
/// <param name="ae"></param>
/// <returns></returns>
public SoundEffectInstance Update3DSoundEffect(SoundEffectInstance se, AudioEmitter ae)
{
se.Apply3D(AvatarListener, ae);
return se;
}
示例6: Apply3D
public static void Apply3D(SoundEffectInstance soundCue)
{
soundCue.Apply3D(listner, emitter);
}
示例7: handleBullets
//.........这里部分代码省略.........
//this is the frame where the bullet is created
if (animation.currentFrame == 18 && bulletAdded == false && (activity == EnemyActivity2.enemyShootDown || activity == EnemyActivity2.enemyShootDiagDown || activity == EnemyActivity2.enemyShootAhead || activity == EnemyActivity2.enemyShootDiagUp || activity == EnemyActivity2.enemyShootUp))
{
Bullet bullet = new Bullet();
if (MainMenuScreen.currentGameScreen == 1)
{
bullet.Texture = GameplayScreen.bulletTex2;
}
else
{
bullet.Texture = GameplayScreen2.bulletTex2;
}
if(animation.myEffect == SpriteEffects.FlipHorizontally) //to the right
{
if (activity == EnemyActivity2.enemyShootDown)
{
bullet.DirectionIncrement = new Vector2(0f, 1f);
bullet.Origin = Position + new Vector2(21f, 70f);
}
else if (activity == EnemyActivity2.enemyShootDiagDown)
{
bullet.DirectionIncrement = new Vector2(0.75f, 0.75f);
bullet.Origin = Position + new Vector2(60f, 50f);
}
else if (activity == EnemyActivity2.enemyShootAhead)
{
bullet.DirectionIncrement = new Vector2(1f, 0f);
bullet.Origin = Position + new Vector2(90f, -5f);
}
else if (activity == EnemyActivity2.enemyShootDiagUp)
{
bullet.DirectionIncrement = new Vector2(0.75f, -0.75f);
bullet.Origin = Position + new Vector2(65f, -73f);
}
else if (activity == EnemyActivity2.enemyShootUp)
{
bullet.DirectionIncrement = new Vector2(0f, -1f);
bullet.Origin = Position + new Vector2(2f, -100f);
}
}
else //to the left
{
if (activity == EnemyActivity2.enemyShootDown)
{
bullet.DirectionIncrement = new Vector2(0f, 1f);
bullet.Origin = Position + new Vector2(-35f, 70f);
}
else if (activity == EnemyActivity2.enemyShootDiagDown)
{
bullet.DirectionIncrement = new Vector2(-0.75f, 0.75f);
bullet.Origin = Position + new Vector2(-87f, 58f);
}
else if (activity == EnemyActivity2.enemyShootAhead)
{
bullet.DirectionIncrement = new Vector2(-1f, 0f);
bullet.Origin = Position + new Vector2(-90f, -5f);
}
else if (activity == EnemyActivity2.enemyShootDiagUp)
{
bullet.DirectionIncrement = new Vector2(-0.75f, -0.75f);
bullet.Origin = Position + new Vector2(-77f, -75f);
}
else if (activity == EnemyActivity2.enemyShootUp)
{
bullet.DirectionIncrement = new Vector2(0f, -1f);
bullet.Origin = Position + new Vector2(-16f, -100f);
}
}
bullet.MaxDistanceFromOrigin = 1500;
bullet.Speed = 6;
bullet.CurrentPos = bullet.Origin;
bullet.DirectionIncrement *= bullet.Speed;
bulletQueue.Enqueue(bullet); //add the bullet to the queue of bullets
bulletAdded = true;
soundEffectInstance = GameStateManagementGame.bearShoot.CreateInstance(); //play bullet sound quitely if far away
if (MainMenuScreen.currentGameScreen == 1)
{
soundEffectInstance.Apply3D(GameplayScreen.audioListener, audioEmitter);
soundEffectInstance.Play();
}
else
{
soundEffectInstance.Apply3D(GameplayScreen2.audioListener, audioEmitter);
soundEffectInstance.Play();
}
}
if (animation.currentFrame > 18 && (activity == EnemyActivity2.enemyShootDown || activity == EnemyActivity2.enemyShootDiagDown || activity == EnemyActivity2.enemyShootAhead || activity == EnemyActivity2.enemyShootDiagUp || activity == EnemyActivity2.enemyShootUp))
{
bulletAdded = false;
}
}
示例8: Update
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
KeyboardState keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyDown(Keys.Space) && prevKeyboardState.IsKeyUp(Keys.Space))
{
currentSound = applause.CreateInstance();
listener = new AudioListener();
listener.Position = camera.Position;
listener.Up = camera.Up;
listener.Forward = camera.Forward;
emitter = new AudioEmitter();
emitter.Position = cube.Position;
emitter.Up = Vector3.Up;
emitter.Forward = -camera.Forward;
currentSound.Apply3D(listener, emitter);
currentSound.Play();
}
cube.RotateY = 0.05f;
cube.RotateX = 0.01f;
MouseState mouseState = Mouse.GetState();
if (mouseState.LeftButton == ButtonState.Pressed && prevMouseState.LeftButton == ButtonState.Released)
{
ray = new Ray();
ray.Position = GraphicsDevice.Viewport.Unproject(
new Vector3(mouseState.X, mouseState.Y, 0),
camera.Projection, camera.View, cube.World);
ray.Direction = GraphicsDevice.Viewport.Unproject(
new Vector3(mouseState.X, mouseState.Y, 1),
camera.Projection, camera.View, cube.World) - ray.Position;
BoundingBox box = new BoundingBox(-Vector3.One, Vector3.One);
if (box.Intersects(ray) != null)
/*if(nextClick == i)*/
{
SetupNext();
currentSound = applause.CreateInstance();
currentSound.Play();
clicked = true;
}
else
{
}
}
listener.Position += Vector3.UnitZ * 0.05f;
currentSound.Apply3D(listener, emitter);
currentSound.Play();
prevKeyboardState = keyboardState;
prevMouseState = mouseState;
cube.Update(gameTime);
base.Update(gameTime);
}
示例9: Update
public void Update(SoundObject soundObj, SoundEffectInstance inst)
{
inst.Volume = soundObj.Volume;
if (Type == SoundType.World || Type == SoundType.Global)
{
SoundEffect.DistanceScale = soundObj.Radius;
inst.Apply3D(listener, soundObj.Emitter);
}
}