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


C# SoundEffect.CreateInstance方法代码示例

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


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

示例1: GetInstance

        private SoundEffectInstance GetInstance(SoundEffect effect)
        {
            #if WINDOWS_PHONE
            // Names of resources for some reason don't work on XNA 4.0 targetting Phone 7.1
            // For now (first release), just don't cache sounds.
            return effect.CreateInstance();
            #else
            if (!_cachedEffects.ContainsKey(effect.Name))
            {
                _cachedEffects.Add(effect.Name, effect.CreateInstance());
            }

            return _cachedEffects[effect.Name];
            #endif
        }
开发者ID:jolson88,项目名称:Hiromi,代码行数:15,代码来源:SoundManager.cs

示例2: playSound

        //plays a sound once and doesn’t store the reference into memory
        public static void playSound(string filename, ContentManager Content)
        {
            int index = 1;
                SoundEffectInstance soundEngineInstance;
                if (lookUpTable.ContainsKey(filename))
                {

                    lookUpTable.TryGetValue(filename, out index);
                    soundEngineInstance = mySounds.ElementAt(index);
                    if (soundEngineInstance.State == SoundState.Paused)
                    {
                        soundEngineInstance.Resume();
                    }
                    else if (soundEngineInstance.State == SoundState.Stopped)
                    {
                        soundEngineInstance.Play();
                    }
                }
                else
                {
                    soundEngine = Content.Load<SoundEffect>(filename);
                    soundEngineInstance = soundEngine.CreateInstance();
                    mySounds.Add(soundEngineInstance);

                    lookUpTable.Add(filename, numSounds);
                    numSounds++;
                    soundEngineInstance.IsLooped = false;
                    soundEngineInstance.Volume = 0.5f;
                    soundEngineInstance.Play();
                }
        }
开发者ID:foolmoron,项目名称:Rolling,代码行数:32,代码来源:Sound.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: Audio

 public Audio(string bestand, bool loop)
 {
     soundEffect = Program.INSTANCE.Content.Load<SoundEffect>(bestand);
     instance = soundEffect.CreateInstance();
     instance.IsLooped = loop;
     playingSound = true;
 }
开发者ID:fmavdb,项目名称:big-mcgreed,代码行数:7,代码来源:Audio.cs

示例5: SoundEffectFile

 /// <summary>
 /// Erstellt eine neue SoundEffect-Datei mit dem angegebenen Anzeigenamen und des angegebenen SoundEffect-Objekts.
 /// </summary>
 public SoundEffectFile(string name, SoundEffect soundEffect, Sound soundType)
 {
     Name = name;
     SoundEffect = soundEffect;
     Instance = soundEffect.CreateInstance ();
     SoundType = soundType;
 }
开发者ID:knot3,项目名称:knot3-code,代码行数:10,代码来源:SoundEffectFile.cs

示例6: PlaySound

        public static void PlaySound(SoundEffect Sound)
        {
            SoundEffectInstance soundEngineInstance;

            soundEngineInstance = Sound.CreateInstance();
            soundEngineInstance.Play();
        }
开发者ID:ZacJ,项目名称:BroodLord,代码行数:7,代码来源:Sounds.cs

示例7: CSound

 public CSound(SoundEffect fx, bool Track)
 {
     _sfxInstance = fx.CreateInstance();
     _sfx = null;
     _song = null;
     _track = Track;
 }
开发者ID:shadowkami,项目名称:King-of-Thieves,代码行数:7,代码来源:CSound.cs

示例8: playSound

 public static void playSound(SoundEffect soundEffect)
 {
     SoundEffectInstance instance = soundEffect.CreateInstance();
     instance.Volume = Game.volume;
     instance.Play();
     soundEffects.Add(instance);
 }
开发者ID:nedearb,项目名称:Specland,代码行数:7,代码来源:SoundEffectPlayer.cs

示例9: LoopingSoundEffect

 public LoopingSoundEffect(SoundEffect soundEffect, float volume)
 {
     sound = soundEffect.CreateInstance();
     sound.IsLooped = true;
     this.volume = sound.Volume = volume;
     LoopingSoundEffects.Add(this);
 }
开发者ID:nubington,项目名称:bill,代码行数:7,代码来源:LoopingSoundEffect.cs

示例10: Init

        public void Init()
        {
            speed = 5;//1000 / speed;
            player = new Player(game, this, new Rectangle(512, 0, 32, 32));
            game.Components.Add(player);
            Block floor = new Block(game, this, new Rectangle(0, 736, 1024, 32), Color.SpringGreen, 0, 0);//740
            blocks.Add(floor);

            game.Components.Add(floor);

            CheckNextBlockSpawn();

            this.highScore = new HighScoresWindow(game);
            game.Components.Add(this.highScore);

            this.scoreText = new Text(game, "Score: " + this.points, new Vector2(0,0), Color.Blue);
            game.Components.Add(this.scoreText);

            music = this.game.Content.Load<SoundEffect>("home_at_last");

            musicInstance = music.CreateInstance();
            musicInstance.IsLooped = true;
            musicInstance.Play();

            points = 0;
        }
开发者ID:tekktonic,项目名称:Apphack6,代码行数:26,代码来源:Level3.cs

示例11: PlayingState

        public PlayingState(Game game)
            : base(game)
        {
            game.Services.AddService(typeof(IPlayingState), this);

            PlayerShip = new Player(OurGame);
            GameThrusterManager = new ThrusterManager(OurGame);

            PlayerShip.GameThrusterManager = GameThrusterManager;

            GameFoodManager = new FoodManager(OurGame);
            PlayerShip.GameFoodManager = GameFoodManager;
            GameFoodManager.PlayerShip = PlayerShip;

            GamePowerupManager = new PowerUpManager(OurGame);
            PlayerShip.GamePowerupManager = GamePowerupManager;
            GamePowerupManager.PlayerShip = PlayerShip;

            OurGame.Components.Add(PlayerShip);
            OurGame.Components.Add(GameThrusterManager);
            OurGame.Components.Add(GameFoodManager);
            OurGame.Components.Add(GamePowerupManager);

            PlayerShip.Enabled = false;
            GameFoodManager.Enabled = false;
            GameThrusterManager.Enabled = false;
            GamePowerupManager.Enabled = false;
            PlayerShip.Visible = false;
            GameFoodManager.Visible = false;
            GameThrusterManager.Visible = false;
            GamePowerupManager.Visible = false;

            soundEffect = Content.Load<SoundEffect>("Music");
            soundEffectIntance = soundEffect.CreateInstance();
        }
开发者ID:guorenxu,项目名称:FoodSpace,代码行数:35,代码来源:PlayingState.cs

示例12: CreateSoundInstance

        public void CreateSoundInstance(string SoundID)
        {
            switch (SoundID)
            {

                case "finalMap1":
                    SoundFromFile = (SoundEffect)ContentRepository.Content["1-"];
                    InstanceOfSound = SoundFromFile.CreateInstance();
                    break;

                case "finalMap2":
                    SoundFromFile = (SoundEffect)ContentRepository.Content["2-"];
                    InstanceOfSound = SoundFromFile.CreateInstance();
                    break;
                case "finalMap3":
                    SoundFromFile = (SoundEffect)ContentRepository.Content["3-"];
                    InstanceOfSound = SoundFromFile.CreateInstance();
                    break;
                case "4":
                    SoundFromFile = (SoundEffect)ContentRepository.Content["4-"];
                    InstanceOfSound = SoundFromFile.CreateInstance();
                    break;
                case "5":
                    SoundFromFile = (SoundEffect)ContentRepository.Content["5-"];
                    InstanceOfSound = SoundFromFile.CreateInstance();
                    break;
                case "6":
                    SoundFromFile = (SoundEffect)ContentRepository.Content["6-"];
                    InstanceOfSound = SoundFromFile.CreateInstance();
                    break;
                default:
                    //throw new Exception("No Sound for this ID");
                    break;
            }
        }
开发者ID:tylermenezes,项目名称:Hunt-the-Wumpus-2010,代码行数:35,代码来源:Sound.cs

示例13: SoundObject

 //Modular Constructor
 public SoundObject(SoundEffect target, Vector2 posn)
 {
     this.sound = target;
     this.position = posn;
     this.isModular = true;
     this.dynamic = sound.CreateInstance();
 }
开发者ID:pquinn,项目名称:time-sink,代码行数:8,代码来源:SoundObject.cs

示例14: Initialize

        public static void Initialize(ContentManager content)
        {
            scream = content.Load<SoundEffect>("Assets/Sounds/deathScream");
            collectSound = content.Load<SoundEffect>("Assets/Sounds/itemCollect");
            checkpointHell = content.Load<SoundEffect>("Assets/Sounds/CheckpointHell");
            checkpointCrystal = content.Load<SoundEffect>("Assets/Sounds/CheckpointCristall");
            fireball = content.Load<SoundEffect>("Assets/Sounds/Fireball");
            freezingIce = content.Load<SoundEffect>("Assets/Sounds/freezingIce");
            whip = content.Load<SoundEffect>("Assets/Sounds/whip");
            laser = content.Load<SoundEffect>("Assets/Sounds/laser");
            SeraphinScream = content.Load<SoundEffect>("Assets/Sounds/SeraphinScream");
            thunder = content.Load<SoundEffect>("Assets/Sounds/thunder");
            spear = content.Load<SoundEffect>("Assets/Sounds/spear");
            claws = content.Load<SoundEffect>("Assets/Sounds/claws");
            mainMenu = content.Load<SoundEffect>("Assets/Sounds/mainMenu");
            menu = mainMenu.CreateInstance();
            menu.IsLooped = true;
            punch = content.Load<SoundEffect>("Assets/Sounds/punch");
            waterSound = content.Load<SoundEffect>("Assets/Sounds/water");
            water = waterSound.CreateInstance();
            spawn = content.Load<SoundEffect>("Assets/Sounds/spawn");
            minionsFraktus = content.Load<SoundEffect>("Assets/Sounds/minions");
            goldCave = content.Load<SoundEffect>("Assets/Sounds/GoldCave");
            cave = goldCave.CreateInstance();
            //cave.IsLooped = true;

            //background crystal
            crystalBackground = content.Load<SoundEffect>("Assets/Sounds/crystalBackground");
            crystalBG = crystalBackground.CreateInstance();
            crystalBG.Volume = 0.25f;
            crystalBG.IsLooped = true;
        }
开发者ID:KleinerMensch,项目名称:CR4VE,代码行数:32,代码来源:Sounds.cs

示例15: SmallMarioJumpEffect

 public SmallMarioJumpEffect()
 {
     backgroundSoundEffect = SoundEffect.FromStream(backgroundSoundFile);
     instance = backgroundSoundEffect.CreateInstance();
     instance.Volume = 0.25f;
     instance.IsLooped = false;
 }
开发者ID:Bartholomew-m134,项目名称:BuckeyeGameEngine,代码行数:7,代码来源:SmallMarioJumpEffect.cs


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