그래서 모션 API를 사용하는 응용 프로그램에서 작업하고 이벤트 핸들을 통해 업데이트하십시오. 문제는 내가 메시지 상자를 표시하는 데 문제가 있고 그 이유를 이해할 수 없습니다. 아래의 기본 코드 :Windows Phone 8 : 메시지 상자가 작동하지 않습니까?
public MainPage()
{
InitializeComponent();
MessageBox.Show("welcome"); //box not showing
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
motion = new Motion();
motion.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20);
motion.CurrentValueChanged +=
new EventHandler<SensorReadingEventArgs<MotionReading>> (motion_CurrentValueChanged);
motion.Start();
}
void motion_CurrentValueChanged(object sender, SensorReadingEventArgs<MotionReading> e)
{
Dispatcher.BeginInvoke(() => CurrentValueChanged(e.SensorReading));
}
private void CurrentValueChanged(MotionReading e)
{
Thickness mar = characterMain.Margin;
txtblck1.Text = "Yaw " + e.Attitude.Yaw.ToString() + " Pitch " + e.Attitude.Pitch + " Roll " + e.Attitude.Roll;
mar.Left = hor + (e.Attitude.Roll * 200);
mar.Top = vert + (e.Attitude.Pitch * 200);
characterMain.Margin = mar;
bool col = engine1.CDetection_V1(characterMain.Margin.Left, characterMain.Margin.Top, characterMain.Width, characterMain.Height, BadGuy.Margin.Left, BadGuy.Margin.Top, BadGuy.Width, BadGuy.Height);
if (col == true)
{
MessageBox.Show("hit");//this doesnt
num.Text = "hit"; //this works
}
}
이 예를 확인할 수 있습니까? http://sdrv.ms/1c0rRXI? – Romasz
이 코드를 내 코드에 추가했지만 테스트되었지만 여전히 운이 없다. 어쨌든 메이트 –
예제를 수정하지 않고 실행 했으므로 MessageBox가 작동 했습니까? – Romasz