Exemplo n.º 1
0
        /// <summary>
        /// 用于回收再利用
        /// 默认调用了LoadContent以及Reinit
        /// 注意的是:screenType不能为Between
        /// </summary>
        /// <param name="screenType">屏幕种类</param>
        /// <param name="createScreen">生成屏幕的方法</param>
        public void ChangeScreenTo(ScreenType screenType, CreateScreen createScreen)
        {
            if (currentScreen != null)
            {
                previousScreenType = currentScreenType;
                previousScreen     = currentScreen;
                //注意,一定要先释放Input资源,并且注意不要重复释放!
                previousScreen.UnloadContent();
            }
            if (!screenDictionary.ContainsKey(screenType))
            {
                /*
                 #region 设置新页面
                 * screenDictionary.Add(screenType, createScreen());
                 * new Thread(new ThreadStart(screenDictionary[screenType].RegistCotent)).Start();
                 * nextScreenType = screenType;
                 * nextScreen = screenDictionary[screenType];
                 #endregion
                 *
                 #region 设置Between页面
                 * //设置BetweenScreen。
                 * //默认存在BetweenScreen
                 * currentScreenType = ScreenType.Between;
                 * currentScreen = screenDictionary[ScreenType.Between];
                 * currentScreen.ReInit();
                 #endregion
                 */
                //为了省事,这是老方法
                screenDictionary.Add(screenType, createScreen());
                currentScreenType = screenType;
                currentScreen     = screenDictionary[screenType];
                currentScreen.BaseLoadContent();
            }
            else
            {
                #region 直接加载新页面
                currentScreenType = screenType;
                currentScreen     = screenDictionary[screenType];
                //重新启动
                currentScreen.ReInit();
                #endregion

                #region 清理资源
                ReleaseScreen();
                //重置nextScreen
                nextScreen = null;
                #endregion
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 只有在加载页面动画完成后才释放资源
 /// </summary>
 public static void ReleaseScreen()
 {
     if (previousScreen != null)
     {
         //重置资源
         //特别注意的是,释放Input资源应该在加载新页面之前!
         SAGlobal.CleanTemporalContent();
         if (previousScreen.Releasable)
         {
             screenDictionary.Remove(previousScreenType);
         }
         //重置指针
         previousScreen = null;
     }
 }