I'm working on a game for Windows Phone 7, I'm using version SLXNA (Silvelight + XNA) and everything I have, the problem is that it takes a lot to navigate the game page (GamePage.xaml), I want to make a page that says "loading ..", because the application stays where it is until you see the game page.
Thanks for your answers. Greetings
You have a few options:
It really depends where do you want the loading to happen. Is it a game loop or a SL page. XNA Thread example:
private Thread thread;
private bool isLoading;
private void LoadResources()
{
// Start loading the resources in an additional thread
thread = new Thread(new ThreadStart(gameplayScreen.LoadAssets));
thread.Start();
isLoading = true;
}
For example LoadResources method is called when user press tap the screen
if (!isLoading)
{
if (input.Gestures.Count > 0)
{
if (input.Gestures[0].GestureType == GestureType.Tap)
{
LoadResources();
}
}
}
In the game update loop
if (null != thread)
{
// If additional thread finished loading and the screen is not
// exiting
if (thread.ThreadState == ThreadState.Stopped && !IsExiting)
{
//start the level
}
}
It's good idea to show something to the user eg
private static readonly string loadingText = "Loading...";
and in the draw loop
if (isLoading)
{
Vector2 size = smallFont.MeasureString(loadingText);
Vector2 messagePosition = new Vector2(
(ScreenManager.GraphicsDevice.Viewport.Width - size.X) / 2,
(ScreenManager.GraphicsDevice.Viewport.Height - size.Y) / 2);
spriteBatch.DrawStringBlackAndWhite(smallFont, loadingText, messagePosition);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.