当前位置: 首页>>代码示例>>C#>>正文


C# SoundEffect.Play方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:danielhba,项目名称:Invasion,代码行数:33,代码来源:Ship.cs

示例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;
        }
开发者ID:nstanley,项目名称:scrolling-shooter,代码行数:36,代码来源:Explosion2.cs

示例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;
 }
开发者ID:vladk1,项目名称:Kaizen,代码行数:7,代码来源:VoiceRecorder.xaml.cs

示例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;
        }
开发者ID:ZaikMD,项目名称:TaleOfTwoHorns,代码行数:16,代码来源:Sounds.cs

示例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);
        }
开发者ID:donbing,项目名称:Invasion-Game,代码行数:12,代码来源:SoundManager.cs

示例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();
 }
开发者ID:SKorolchuk,项目名称:ArtificialSpace,代码行数:8,代码来源:Effect.cs

示例7: Collect

 public void Collect(Rectangle loc, Level level, SoundEffect pearSound)
 {
     if (loc.Intersects (location) && !collected) {
         level.numCollected++;
         pearSound.Play ();
         collected = true;
     }
 }
开发者ID:johnluscombe,项目名称:GameJamF15,代码行数:8,代码来源:Collectible.cs

示例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);
 }
开发者ID:NAWEB-USP,项目名称:SmartAudioCityGuide,代码行数:8,代码来源:AddRoutePlace.xaml.cs

示例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);
     }
 }
开发者ID:havri,项目名称:ActionGame,代码行数:13,代码来源:SoundPlayer.cs

示例10: playEffect

 public void playEffect(String soundname, ContentManager content, bool sound)
 {
     if (sound == true)
     {
         effect = content.Load<SoundEffect>(soundname);
         effect.Play();
     }
 }
开发者ID:TehRobRoy,项目名称:GGJ2012,代码行数:8,代码来源:CAudio.cs

示例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();
 }
开发者ID:meszka,项目名称:bomber,代码行数:8,代码来源:Explosion.cs

示例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();
     }
 }
开发者ID:Bootz,项目名称:VoIP_Project_Archives_Testing,代码行数:10,代码来源:AudioDeviceResource.cs

示例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();
        }
开发者ID:ppaier,项目名称:GameProgrammingCSharp,代码行数:15,代码来源:Explosion.cs

示例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();
        }
开发者ID:Vintharas,项目名称:WP7projects,代码行数:13,代码来源:Game1.cs

示例15: handleCollision

 public void handleCollision(Vector2 collisionVect, SoundEffect playSound)
 {
     if (collisionCD <= 0)
     {
         mVelocity = collisionVect;
         collisionCD = 60;
         playSound.Play();
         mEffect.init();
     }
 }
开发者ID:nuts4nuts4nuts,项目名称:graphics,代码行数:10,代码来源:Punchee.cs


注:本文中的Microsoft.Xna.Framework.Audio.SoundEffect.Play方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。