Windows phone 7 尝试使用XNA播放音效
我正在使用XNa的soundeffect对象为windows phone编写第一个应用程序,它将是一个音板 该项目是一个Windows phone Silverlight和Xna应用程序c# 我从书中得到了一些示例代码,101 phone 7应用程序。 声音中要加载的linbe给了我一个 “找不到类型StreamResourceInfo命名空间” StreamResourceInfo=Application.GetResourceStream(新Uri(“Audio/cowbell.wav”,UriKind.Relative)) 代码Windows phone 7 尝试使用XNA播放音效,windows-phone-7,Windows Phone 7,我正在使用XNa的soundeffect对象为windows phone编写第一个应用程序,它将是一个音板 该项目是一个Windows phone Silverlight和Xna应用程序c# 我从书中得到了一些示例代码,101 phone 7应用程序。 声音中要加载的linbe给了我一个 “找不到类型StreamResourceInfo命名空间” StreamResourceInfo=Application.GetResourceStream(新Uri(“Audio/cowbell.wav”,U
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework.Audio;
namespace SlXnaApp4
{
public partial class MainPage : PhoneApplicationPage
{
SoundEffect cowbell;
// Constructor
public MainPage()
{
// Load sound file
StreamResourceInfo info = Application.GetResourceStream(new Uri("Audio/cowbell.wav", UriKind.Relative));
// create xna sound
cowbell = SoundEffect.FromStream(info);
// Sub to per frame call back
CompositionTarget.Rendering += CompositionTarget_Rendering;
// requred for xna sound effects to work
Microsoft.Xna.Framework.FrameworkDispatcher.Update();
// testb sound
cowbell.Play();
InitializeComponent();
}
void CompositionTarget_Rendering(object sender, EventArgs e)
{
Microsoft.Xna.Framework.FrameworkDispatcher.Update();
}
// Simple button Click event handler to take us to the second page
private void Button_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative));
}
private void button1_Click(object sender, RoutedEventArgs e)
{
}
}
}为以下内容添加使用指令:
您是否添加了对
System.Windows
的引用?System.Windows
在默认情况下始终被引用。
using System.Windows.Resources;