protected override void UnloadContent() { if (nextScreen != null) { nextScreen.Dispose(); } if (screen != null) { screen.Dispose(); } if (spriteBatch != null) { spriteBatch.Dispose(); } if (fillTexture != null) { fillTexture.Dispose(); } if (ScreenFactory != null && ScreenFactory.Initialized) { ScreenFactory.Dispose(); } base.UnloadContent(); }
public override void Update(GameTime gameTime) { // 次の Screen が設定されているならば切り替えます。 if (nextScreen != null) { if (screen != null) { // MouseDevice をアンバインドします。 screen.MouseDevice = null; // KeyboardDevice をアンバインドします。 screen.KeyboardDevice = null; // 破棄します。 // MEMO: 恐らく他のタイミングでは明示的に Dispose を呼ぶのが難しい。 screen.Dispose(); } screen = nextScreen; if (screen != null) { // MouseDevice をバインドします。 screen.MouseDevice = mouseDevice; // KeyboardDevice をバインドします。 screen.KeyboardDevice = keyboardDevice; } nextScreen = null; } // ユーザ入力を処理します。 ProcessInput(); // Screen を更新します。 screen.Update(gameTime); base.Update(gameTime); }