Forum begins after the advertisement:
[Part 18] When the Level Up screen is displayed…
Home › Forums › Video Game Tutorial Series › Creating a Rogue-like Shoot-em Up in Unity › [Part 18] When the Level Up screen is displayed…
- This topic has 3 replies, 2 voices, and was last updated 2 months, 4 weeks ago by 정춤고 (ChoomGo).
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
October 11, 2024 at 5:17 am #16025::
When the Level Up screen is displayed, pressing the Esc button causes the game to pause, so I modified the code. What I want is for the Paused screen to be able to activate or deactivate even when the Level Up screen is active, but despite modifying the code, the Paused screen does not activate when the Level Up screen is displayed. How can I resolve this issue? I need your help, Mr.
GameManager.cs
<code> public void PauseGame() { if (currentState != GameState.Paused) { previousState = currentState; ChangeState(GameState.Paused); Time.timeScale = 0f; pauseScreen.SetActive(true); } } public void ResumeGame() { if (currentState == GameState.Paused) { if (currentState == GameState.Paused) { ChangeState(previousState); Time.timeScale = (currentState == GameState.LevelUp) ? 0f : 1f; pauseScreen.SetActive(false); } } } void CheckForPauseAndResume() { if (Input.GetKeyUp(KeyCode.Escape)) { if (currentState == GameState.Paused) { ResumeGame(); } else { if (currentState == GameState.LevelUp) { pauseScreen.SetActive(true); } else { PauseGame(); } } } }</code>
October 24, 2024 at 5:25 pm #16164October 25, 2024 at 1:15 am #16171October 25, 2024 at 2:57 am #16172::Thank you, I managed to solve it somehow. Your help was really valuable.
<code> case GameState.GameOver: case GameState.LevelUp: CheckForPauseAndResume(); break; </code>
<code>public void ResumeGame() { if (currentState == GameState.Paused || currentState == GameState.LevelUp) { ChangeState(previousState); Time.timeScale = (currentState == GameState.LevelUp) ? 0f : 1f; pauseScreen.SetActive(false); } }</code>
<code>void CheckForPauseAndResume() { if (Input.GetKeyUp(KeyCode.Escape)) { if (currentState == GameState.Paused) { ResumeGame(); } else if (currentState == GameState.LevelUp) { if (pauseScreen.activeSelf) { ResumeGame(); //pauseScreen.SetActive(false); } else { pauseScreen.SetActive(true); } } else { PauseGame(); } } }</code>
has upvoted this post. -
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Advertisement below: