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


C# SoundEffectInstance.Play方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Audio.SoundEffectInstance.Play方法的典型用法代码示例。如果您正苦于以下问题:C# SoundEffectInstance.Play方法的具体用法?C# SoundEffectInstance.Play怎么用?C# SoundEffectInstance.Play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Audio.SoundEffectInstance的用法示例。


在下文中一共展示了SoundEffectInstance.Play方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

        public void Update(GameManager gameManager, Menu menu, Carte map)
        {
            if (nouveaujeu == false && gameManager.Etat == GameManager.etat.NouveauJeuIntro)
            {
                sonmanager.Stop();
                sonmanager = sons[5].CreateInstance();
                sonmanager.IsLooped = true;
                sonmanager.Play();
                nouveaujeu = true;
            }

            if (jeu == false && gameManager.Etat == GameManager.etat.InGame)
            {
                jeu = true;
            }

            if (!menu.pauseactive)
            {
                if (menu.sound == Menu.Son.On && sonmanager.State == SoundState.Paused)
                {
                    sonmanager.Play();
                }

                if (menu.sound == Menu.Son.Off && sonmanager.State == SoundState.Playing)
                {
                    sonmanager.Pause();
                }
            }

            if(menu.pauseactive)
            {
                if (sonmanager.State == SoundState.Playing)
                    sonmanager.Pause();
            }
        }
开发者ID:HunterB06,项目名称:Dragon-Tears,代码行数:35,代码来源:SoundManager.cs

示例2: EndScreen

        public EndScreen(ADHDGame g, SpriteBatch spb, Ending e)
            : base(g, spb)
        {
            end = e;
            sb = spb;
            game = g;
            banjoEnd = game.Content.Load<Texture2D>("newspaper_death01");
            space = game.Content.Load<Texture2D>("spaceBG");
            explosion = game.Content.Load<SoundEffect>("Explosion").CreateInstance();
            airlockEnd = game.Content.Load<Texture2D>("newspaper_death02");
            blackhole = game.Content.Load<Texture2D>("newspaper_death03");
            breaks = game.Content.Load<Texture2D>("newspaper_death04");
            thrusters = game.Content.Load<Texture2D>("newspaper_death05");
            tutorial = game.Content.Load<Texture2D>("tutorial");
            inactive = game.Content.Load<Texture2D>("newspaper_death06");
            dub = game.Content.Load<Texture2D>("newspaper_death07");
            help = game.Content.Load<Texture2D>("newspaper_death08");

            explosion.Play();

            if (e != Ending.Banjo)
            {
                MediaPlayer.Play(game.Content.Load<Song>("SpaceRock_V1"));
            }
        }
开发者ID:Raidenthequick,项目名称:T01H,代码行数:25,代码来源:EndScreen.cs

示例3: GameStateManagementGame

        public GameStateManagementGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);
            //TargetElapsedTime = TimeSpan.FromTicks(333333);
            TargetElapsedTime = TimeSpan.FromTicks(333);

            #if WINDOWS_PHONE
            graphics.IsFullScreen = true;
            InitializeLandscapeGraphics();
            #endif

            screenFactory = new ScreenFactory();
            Services.AddService(typeof(IScreenFactory), screenFactory);
            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            #if WINDOWS_PHONE
            // hook
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Launching +=
                new EventHandler<Microsoft.Phone.Shell.LaunchingEventArgs>(GameLaunching);
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Activated +=
                new EventHandler<Microsoft.Phone.Shell.ActivatedEventArgs>(GameActivated);
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Deactivated +=
                new EventHandler<Microsoft.Phone.Shell.DeactivatedEventArgs>(GameDeactivated);
            #else
            AddInitialScreens();
            #endif
            gameMusic = Content.Load<SoundEffect>("sounds/GamePlayHalfBit");
            gameMusicI = gameMusic.CreateInstance();
            gameMusicI.IsLooped = true;
            gameMusicI.Play();
        }
开发者ID:alexcoco,项目名称:trace_racer,代码行数:34,代码来源:Celestial.cs

示例4: Boat

        public Boat(EnemyType type, Vector2 position, Texture2D sheet, int scene)
            : base(type, position, sheet, scene)
        {
            spawnPosition = position;
            numFrames = 1;
            animTime = 50;
            isAnimating = true;
            animFrame = 0;

            Speed = 0.003f;

            frameSize = new Vector2(64,64);
            frameOffset = new Vector2(32, 20);
            hitRadius = 25;

            centerOffestLength = 0;

            fireRate = 50;
            fireCountdown = 50;

            HP = 20;

            Target = GameManager.Hero.Position + Helper.AngleToVector(GameManager.Hero.spriteRot, 400f);

            chopperSound = AudioController.effects["boat"].CreateInstance();
            chopperSound.Volume = 0f;
            chopperSound.IsLooped = true;
            chopperSound.Play();
        }
开发者ID:GarethIW,项目名称:GravWalker,代码行数:29,代码来源:Boat.cs

示例5: playBackground

 public void playBackground(byte theme)
 {
     if (currentBackground != null) currentBackground.Stop();
     currentBackground = backgroundSounds[theme].CreateInstance();
     currentBackground.IsLooped = true;
     currentBackground.Play();
 }
开发者ID:kayorga,项目名称:3DSP,代码行数:7,代码来源:AudioManager.cs

示例6: Update

        public void Update(GameManager gameManager, Menu menu)
        {
            if (jeu && gameManager.Etat == GameManager.etat.InGame)
            {
                sonmanager.Stop();
                sonmanager = sons[2].CreateInstance();
                sonmanager.IsLooped = false;
                sonmanager.Play();
                jeu = false;
            }

            if (gameManager.Etat == GameManager.etat.InGame && sonmanager.State == SoundState.Stopped)
            {
                piste++;
                if (piste == 1)
                {
                    sonmanager.Stop();
                    sonmanager = sons[2].CreateInstance();
                    sonmanager.IsLooped = false;
                    sonmanager.Play();
                }
                else if (piste == 2)
                {
                    sonmanager.Stop();
                    sonmanager = sons[3].CreateInstance();
                    sonmanager.IsLooped = false;
                    sonmanager.Play();
                }
                else if (piste == 3)
                {
                    sonmanager.Stop();
                    sonmanager = sons[4].CreateInstance();
                    sonmanager.IsLooped = false;
                    sonmanager.Play();
                }
                else
                {
                    piste = 0;
                }
            }

            if (!menu.pauseactive)
            {
                if (menu.sound == Menu.Son.On && sonmanager.State == SoundState.Paused)
                {
                    sonmanager.Play();
                }

                if (menu.sound == Menu.Son.Off && sonmanager.State == SoundState.Playing)
                {
                    sonmanager.Pause();
                }
            }

            if(menu.pauseactive)
            {
                if (sonmanager.State == SoundState.Playing)
                    sonmanager.Pause();
            }
        }
开发者ID:Darkrely,项目名称:Seconde_soutenance,代码行数:60,代码来源:SoundManager.cs

示例7: TitleScreen

        public TitleScreen(ADHDGame g, SpriteBatch spb)
            : base(g,spb)
        {
            RobotActions.Instance.energy = 20;
            paper = false;
            mouse = false;
            game = g;
            sb = spb;
            titleSequence = new List<Texture2D>(40);
            gs = new GameplayScreen(g, spb);
            titleAnim = new Animation(new Rectangle(0, 0, 1024, 768), 40, 30, true);
            introNews = g.Content.Load<Texture2D>("newspaper_intro");
            space = g.Content.Load<Texture2D>("spaceBG");
            int i;
            for (i = 0; i < 40; i++)
            {
                titleSequence.Add(g.Content.Load<Texture2D>("titlescreen\\titlescreen" + (i+1).ToString()));
            }
            snoring = g.Content.Load<SoundEffect>("Snoring").CreateInstance();
            alarm = g.Content.Load<SoundEffect>("alarm_02").CreateInstance();

            alarm.IsLooped = true;
            alarm.Volume = 0.2f;
            snoring.IsLooped = true;
            snoring.Play();
        }
开发者ID:Raidenthequick,项目名称:T01H,代码行数:26,代码来源:TitleScreen.cs

示例8: SpriteCollision

        //Obtain how far collide with the object and move back to original position
        //For Player sprite
        public void SpriteCollision(ref Character name, SoundEffectInstance song6Inst, SoundEffectInstance song7Inst)
        {
            //Temporary Value for Object position
            Vector2 currentPos;

            //Difference between each objects edges
            Vector2 Diff = new Vector2(0, 0);

            //Obtain difference from Actionhandler
            Diff = CollisionCheck(name.SpriteID);

            //For X axis difference
            if (Math.Abs(Diff.X) > 0)
            {
                //Sounds for colliding into object
                song6Inst.Volume = 1.0f;
                song6Inst.Play();
                currentPos = name.pos;
                currentPos.X -= Diff.X;
                name.pos = currentPos;
            }
            //For Y axis difference
            if (Math.Abs(Diff.Y) > 0)
            {
                //Sounds for colliding into object
                song7Inst.Volume = 1.0f;
                song7Inst.Play();
                currentPos = name.pos;
                currentPos.Y -= Diff.Y;
                name.pos = currentPos;
            }
        }
开发者ID:csce3513,项目名称:Team18,代码行数:34,代码来源:Collision.cs

示例9: 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;
        }
开发者ID:Aryn,项目名称:Mobile-Fortress,代码行数:27,代码来源:ShipObj.cs

示例10: Play

        public void Play(string soundEffectName, bool isLooped,float volume)
        {
            soundEffect = gestionnaireDeSoundEffect.Find(soundEffectName);
            
            if (!(listeSound.Contains(soundEffectName)))
            {
                listeSound.Add(soundEffectName);
                soundEffectInstanceList.Add(soundEffect.CreateInstance());
            }
            for(int i = 0; i < listeSound.Count;++i)
            {
                test = string.Compare(listeSound[i], soundEffectName) == 0;
                if (test)
                {
                    index = i;
                    break;
                }

            }
            test = false;
            soundEffectInstance = soundEffectInstanceList[index];
            
            if (isLooped && !estRentré)
            {
                soundEffectInstance.IsLooped = true;
                estRentré = true;
            }
            soundEffectInstance.Volume = volume;
            if(!(soundEffectInstance.State == SoundState.Playing))
                soundEffectInstance.Play();
        }
开发者ID:Slagathor08,项目名称:Projet_Finale_Programmation,代码行数:31,代码来源:SoundManager.cs

示例11: Menu

 public Menu(ContentManager Content, SpriteBatch spriteBatch)
 {
     menuTexture = new AnimatedSprite(Content.Load<Texture2D>("Graphics\\MainMenu"), 3, 2, animationSpeed);
     startButton = new Button(new Vector2(startButtonLX, startButtonLY),
         new Vector2(startButtonRX, startButtonRY), "", Vector2.Zero);
     controlsButton = new Button(new Vector2(controlsButtonLX, controlsButtonLY),
         new Vector2(controlsButtonRX, controlsButtonRY), "", Vector2.Zero);
     skipButton = new Button(new Vector2(skipButtonLX, skipButtonLY),
         new Vector2(skipButtonRX, skipButtonRY), "", Vector2.Zero);
     buttonList = new List<Button>() { startButton, skipButton, controlsButton };
     buttonListHover = new List<bool>() { hoverFlag, hoverFlagSkip, hoverFlagControls };
     pixel = new Texture2D(spriteBatch.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
     pixel.SetData(new[] { Color.White });
     isInControllerMenu = false;
     controllerMenu = new ControllerMenu(Content, spriteBatch);
     selectedButton = 0;
     menuBgm = (Content.Load<SoundEffect>("Music\\Cylinder_Eight.wav")).CreateInstance();
     windEffectInstance = (Content.Load<SoundEffect>("Music\\Wind.wav")).CreateInstance();
     flagEffectInstance = (Content.Load<SoundEffect>("Music\\Flag.wav")).CreateInstance();
     scrollClickEffectInstance = (Content.Load<SoundEffect>("Music\\Click.wav")).CreateInstance();
     confirmClickEffectInstance = (Content.Load<SoundEffect>("Music\\Click2.wav")).CreateInstance();
     menuBgm.IsLooped = true;
     menuBgm.Play();
     windEffectInstance.IsLooped = true;
     windEffectInstance.Volume = windVolume;
     flagEffectInstance.IsLooped = true;
     flagEffectInstance.Volume = flagVolume;
     scrollClickEffectInstance.Volume = clickVolume;
     confirmClickEffectInstance.Volume = clickVolume;
     windEffectInstance.Play();
     flagEffectInstance.Play();
 }
开发者ID:pel5xq,项目名称:InFoxholesGame,代码行数:32,代码来源:Menu.cs

示例12: PlayTheme

 public static void PlayTheme()
 {
     _themeIntance = _theme.CreateInstance();
      _themeIntance.IsLooped = true;
      _themeIntance.Volume = .8f;
      _themeIntance.Play();
 }
开发者ID:BLesnau,项目名称:weddinggame,代码行数:7,代码来源:SoundHelper.cs

示例13: City

        public static Area City(Character player)
        {
            if (Sound != null)
                Sound.Stop();

            Sound = ContentLoader.TownSong.CreateInstance();
            Sound.IsLooped = true;
            Sound.Play();

            Point levelrange = new Point(3, 8);
            var map = ContentLoader.City;

            Vector2 spawn = Vector2.One;
            if (player.PreviousArea != null)
                if (player.PreviousArea.Name == "Shop") {
                    spawn = new Vector2(256, 192);
                }
                else if (player.PreviousArea.Name == "Route 1") {
                    spawn = new Vector2(256, 416);
                }
                else {
                    spawn = new Vector2(32, 96);
                }

            List<Monster> monsters = new List<Monster>();
            List<Character> opponents = new List<Character>();
            //Sound = ContentLoader.RouteSong;
            //Sound.IsLooped = true;
            //Sound.Play();

            return new Area("City", levelrange, monsters, opponents, spawn, map);
        }
开发者ID:DuckDefense,项目名称:duck,代码行数:32,代码来源:Area.cs

示例14: CreatePlane

        public void CreatePlane()
        {
            // Already created plane?
            if (plane != -1)
            {
                factory.Objects[plane].sprite.Location = new Vector2(-LengthAddedfromZoom - factory.Objects[plane].sprite.BoundingBoxRect.Width, -650);
                return;
            }

            plane = factory.Create((int)RaginRovers.GameObjectTypes.PLANE,
                Vector2.Zero,
                "plane_with_banner",
                Vector2.Zero,
                0f,
                0f,
                0f);
            factory.Objects[plane].sprite.Location = new Vector2(-LengthAddedfromZoom - factory.Objects[plane].sprite.BoundingBoxRect.Width, -850); //moved plane up 100 pixels so won't collide with that one map
            factory.Objects[plane].sprite.Scale = 2;
            factory.Objects[plane].sprite.PhysicsBodyFixture = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(factory.Objects[plane].sprite.BoundingBoxRect.Width), ConvertUnits.ToSimUnits(factory.Objects[plane].sprite.BoundingBoxRect.Height), 1, ConvertUnits.ToSimUnits(new Vector2(0, 0)), factory.Objects[plane].sprite.PhysicsBody);
            factory.Objects[plane].sprite.PhysicsBodyFixture.OnCollision += new OnCollisionEventHandler(factory.Objects[plane].sprite.HandleCollision);
            factory.Objects[plane].saveable = false;

            soundBuzz = AudioManager.Instance.GetSoundEffectLooped("airplane");
            soundBuzz.Volume = 0.2f;
            soundBuzz.Play();

            isCreated = true;
        }
开发者ID:BenMatase,项目名称:RaginRovers,代码行数:28,代码来源:PlaneManager.cs

示例15: TitleScene

        public TitleScene()
        {
            m_TitleTexture = HeartAttack.theGameInstance.Content.Load<Texture2D>("title");
            m_HeartcoreTexture = HeartAttack.theGameInstance.Content.Load<Texture2D>("heartcoreMode");
            m_FlowTexture = HeartAttack.theGameInstance.Content.Load<Texture2D>("flowMode");

            bgm = HeartAttack.theGameInstance.Content.Load<SoundEffect>("heartbackground").CreateInstance();
            bgm.Play();

            HeartAttack.theGameInstance.bugsKilled = 0;
            HeartAttack.theGameInstance.shotsFired = 0;
            int space = 20;

            m_FlowRectangle = new Rectangle(
                HeartAttack.theGameInstance.graphics.GraphicsDevice.Viewport.Width -
            m_FlowTexture.Width - space,
            HeartAttack.theGameInstance.graphics.GraphicsDevice.Viewport.Height -
            m_FlowTexture.Height - 2 * space - m_HeartcoreTexture.Height, m_FlowTexture.Width, m_FlowTexture.Height);

            m_HeartcoreRectangle = new Rectangle(
                HeartAttack.theGameInstance.graphics.GraphicsDevice.Viewport.Width -
            m_HeartcoreTexture.Width - space,
            HeartAttack.theGameInstance.graphics.GraphicsDevice.Viewport.Height -
            m_HeartcoreTexture.Height - space, m_HeartcoreTexture.Width, m_HeartcoreTexture.Height);
        }
开发者ID:Davermouse,项目名称:HeartAttack,代码行数:25,代码来源:TitleScene.cs


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