Xna 加载sound effect和sound effect实例后获取错误 ExplosionSound=Content.Load(“爆炸”); ExplosionSoundInstance=ExplosionSound.CreateInstance();

Xna 加载sound effect和sound effect实例后获取错误 ExplosionSound=Content.Load(“爆炸”); ExplosionSoundInstance=ExplosionSound.CreateInstance();,xna,Xna,上面代码的最后一行有下划线,我得到一个错误,说明: 无法将类型“Microsoft.Xna.Framework.Audio.SoundEffectInstance”隐式转换为Microsoft.Xna.Framework.Audio.SoundEffect 非常感谢您的帮助。看起来您被宣布为ExplosionSoundInstance作为SoundEffect 将其声明为SoundEffectInstance ExplosionSound = Content.Load<SoundEffec

上面代码的最后一行有下划线,我得到一个错误,说明: 无法将类型“Microsoft.Xna.Framework.Audio.SoundEffectInstance”隐式转换为Microsoft.Xna.Framework.Audio.SoundEffect


非常感谢您的帮助。

看起来您被宣布为ExplosionSoundInstance作为SoundEffect

将其声明为SoundEffectInstance

ExplosionSound = Content.Load<SoundEffect>("explosion");
            ExplosionSoundInstance = ExplosionSound.CreateInstance();
SoundEffectInstance ExplosionSoundInstance;