本文整理汇总了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
}
示例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();
}
}
示例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();
}
示例4: Audio
public Audio(string bestand, bool loop)
{
soundEffect = Program.INSTANCE.Content.Load<SoundEffect>(bestand);
instance = soundEffect.CreateInstance();
instance.IsLooped = loop;
playingSound = true;
}
示例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;
}
示例6: PlaySound
public static void PlaySound(SoundEffect Sound)
{
SoundEffectInstance soundEngineInstance;
soundEngineInstance = Sound.CreateInstance();
soundEngineInstance.Play();
}
示例7: CSound
public CSound(SoundEffect fx, bool Track)
{
_sfxInstance = fx.CreateInstance();
_sfx = null;
_song = null;
_track = Track;
}
示例8: playSound
public static void playSound(SoundEffect soundEffect)
{
SoundEffectInstance instance = soundEffect.CreateInstance();
instance.Volume = Game.volume;
instance.Play();
soundEffects.Add(instance);
}
示例9: LoopingSoundEffect
public LoopingSoundEffect(SoundEffect soundEffect, float volume)
{
sound = soundEffect.CreateInstance();
sound.IsLooped = true;
this.volume = sound.Volume = volume;
LoopingSoundEffects.Add(this);
}
示例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;
}
示例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();
}
示例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;
}
}
示例13: SoundObject
//Modular Constructor
public SoundObject(SoundEffect target, Vector2 posn)
{
this.sound = target;
this.position = posn;
this.isModular = true;
this.dynamic = sound.CreateInstance();
}
示例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;
}
示例15: SmallMarioJumpEffect
public SmallMarioJumpEffect()
{
backgroundSoundEffect = SoundEffect.FromStream(backgroundSoundFile);
instance = backgroundSoundEffect.CreateInstance();
instance.Volume = 0.25f;
instance.IsLooped = false;
}