Hello,
at the moment I´m programming a simple “SideScroller”-Game. Collecting Points, Timer and Restarting Level. All these things were done alread.
Now I´m wanted to have a “Levelmenu”, where you can pause the game or go back to the main-menu. Well one button for “Main-Menu”, one button for “Pause” and one button for “resume”, thats easy to done using switch statements.
But in the end, I don´t like these menu. Pausing and Resuming a game with 2 buttons? Thats not good in my opinion.
So in the end in my Level-Meu should have these following buttons:
- “Main Menu”
-“Resume” and “Pause” as one button
By clicking e.g. “Resume”, the game resumes and the button “Pause” comes. For clicking “Pause” the other way.
I´m using strings for the names of the buttons
Is it possible to use switch stetements for this? If yes, how can I do it? Has someone a example for that?
I´m writing the game in JavaScript.
– TemplateROk! no problem, Here is the logic behind this. 1. At the time level load define variable as int (touchCount) type and save its state in playerPrefab. 2. Detect click or touch on the button. 3. At each click/touch increase value of touchCount. 4. Get the value of touchCount % 2. 5. If value is 1, setTime.TimeScale = 1,(Play the game) and save the value of touchCount in PlayerPrefab. 6. Else value is 0, set timt.timeScale = 0, (Pause the game) and save the value of touchCount in PlayerPrefab. you skip touchCount value to store in playerPrefab. But i suggest you to store.
– DhiruI think, that you haven´t read my questions: 1. Is it possible to use switch stetements for this? 2. how can you do that? (if the answer of the first question is yes) I made a LevelMenu with 3 Buttons using the switch-statements. And I wanted, if it possible to keep it.
– TemplateRYou can write a separate script for your Menu. If you want to use Switch statement then you have to increment the touchCount in the case of play/pause button click. you have to check touchCount value inside update & outside of switch statement. Do the rest of this as you want based on conditions.
– Dhiruyes, but in JavaScript? How it looks?
– TemplateR