0

私は Windows Phone 7 用のゲームに取り組んでいます。バージョン SLXNA (Silvelight + XNA) を使用しています。問題は、ゲーム ページ (GamePage.xaml) をナビゲートするのに時間がかかることです。ゲームページが表示されるまで、アプリケーションはそのままの場所にとどまるため、「ロード中..」というページを作成します。

回答ありがとうございます。ご挨拶

4

1 に答える 1

0

いくつかのオプションがあります:

ロードをどこで行いたいかによって異なります。ゲームループかSLページか。XNA スレッドの例:

    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;
    }

たとえば、ユーザーが画面をタップすると LoadResources メソッドが呼び出されます

        if (!isLoading)
        {
            if (input.Gestures.Count > 0)
            {
                if (input.Gestures[0].GestureType == GestureType.Tap)
                {
                    LoadResources();
                }
            }
        }

ゲームの更新ループで

        if (null != thread)
        {
            // If additional thread finished loading and the screen is not
            // exiting
            if (thread.ThreadState == ThreadState.Stopped && !IsExiting)
            {
               //start the level
            }
        }

ユーザーに何かを表示するのは良い考えです。

        private static readonly string loadingText = "Loading...";

そして描画ループで

        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);
        }
于 2012-09-17T02:42:25.463 に答える