I'm working on porting a game engine from Java to Windows Phone 7 XNA. One thing I'm struggling with is how to create modal dialogs. The dialog is rendered in XNA using SpriteBatch just like everything else, but what I basically want is something like this:
result = Dialog.Ask("Some Question?", DialogButtons.YesNo);
Where Dialog.Ask
doesn't return until the user clicks one of the buttons. The only thing I've done to come close is a method to continuously call RunOneFrame()
on the game:
private int runLoopCount;
public void BeginRunLoop() {
int runIndex = ++runLoopCount;
while (runLoopCount == runIndex) {
RunOneFrame();
Thread.Sleep(1);
}
}
public void EndRunLoop() {
--runLoopCount;
}
There are a few problems with this:
RunOneFrame
is only supposedly for debugging purposes.- Input doesn't work! Calling
TouchPanel.GetState()
orGamePad.GetState(PlayerIndex.One)
doesn't return new values.
Is there any way to initiate a run loop without throwing away the Game class and all it does for initialization? And I don't really know how to do without the Game class anyway, as there is no Main() method in Windows Phone 7 XNA applications. It just goes right into the Game constructor.