You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

2 Días
2 Hrs
34 Min
26 Seg

Terminando el juego

33/34
Resources

How to close the gameplay of a game with Unity?

Creating a video game can seem like a monumental task, but with tools like Unity, the process becomes much more accessible. In this guide, we will explore how to end the 'gameplay loop' of a game, incorporating a splash screen and managing game states effectively. Let's learn together how to do it!

How to create a splash screen similar to Game Over?

To start the development of a splash screen in Unity, we can take advantage of the already created Game Over splash screen interface. Here is the step-by-step to achieve it:

  1. Duplicate the Game Over screen: Within Unity, select the Game Over interface and duplicate it with Ctrl-D or Cmd-D.

  2. Modify the duplicated interface:

    • Rename the duplicate to UI Start Screen.
    • Set the screen color to white to differentiate it.
    • Update the title with the name of your game, e.g. "Safari Match".
    • Remove unnecessary elements such as the dots and one of the action buttons.
    • Redefine the space between the game name and the start button to make it more balanced.
  3. Customize the visual elements:

    • Change the title color to a friendlier shade, such as blue.
    • Rename the "Play Again" button to btnStartGame and modify its text to "Start".
  4. Adjust components:

    • Removes the Game Over component in the Start Screen UI.
    • Change the visible state of Game Over to Idle.

What scripts do we need for the Start Screen?

Interactivity is essential, and for the "Start" button to work properly, it is crucial to create a new script. Here's how to do it:

  1. Create a new script in Unity:

    • In the scripts folder, generate a new script called UI Start Screen.
  2. Implement the start button function:

    • Open the script and add the public function start btnClicket, which will be executed when "Start" is clicked.
    • Inside this function, call the Game Manager instance and execute StartGame.
  3. Add the StartGame function to the Game Manager:

    • Declares a new function public void StartGame in the Game Manager script.
    • Change the game state to GameState.inGame.
    • Make sure the currentTimeToMatch is set to zero.
    • This function should be similar to RestartGame, but keep them separate for clarity and future flexibility.

How to test and close the game loop?

After making all the necessary configurations and settings, it is time to test the game to make sure it works as expected.

  1. Configure click events:

    • In Unity's UI Start Screen, add the UI StartScreen component.
    • Associate the StartGame button click event to call UI StartScreen and its StartButton click it function.
  2. Test the game flow:

    • Run the game to check that when pressing "Start", the game starts properly.
    • Make sure that the logic allows you to make matches, accumulate points, and reach a Game Over that returns you to the initial screen.
    • Perform tests to validate that the "ExitGame" button effectively returns to the start screen, confirming that the loop is closed.

Congratulations! You have now learned how to implement a start screen from scratch and close the game flow. Although video game development can be complex, each step is a significant advancement. Keep exploring and improving your skills, constant practice will take you far in this fascinating world of game development.

Contributions 3

Questions 0

Sort by:

Want to see more contributions, questions and answers from the community?

![]()Me puse a toquetear los valores del TMPro y añadí una imagen de fondo para mejorar la UI del menú inicial, así me quedó:![](https://static.platzi.com/media/user_upload/image-78451470-2605-4f98-abf4-664e2a5e13b9.jpg)
el juego esta lleno de bug. no se como solucionarlos. el profe no responde. copie el codigo tal cual esta echo por el profe. y además no se inicia ni en android, ni en win. la verdad que bastante flojo todo. lo peor es que no tengo respuestas algunas
DOTWEEN ► Target or field is missing/null () ► The object of type 'Transform' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. at (wrapper managed-to-native) UnityEngine.Transform.set\_localScale\_Injected(UnityEngine.Transform,UnityEngine.Vector3&) at UnityEngine.Transform.set\_localScale (UnityEngine.Vector3 value) \[0x00000] in \<cd86b0d4df634b6a8fd612065f941dcd>:0 at DG.Tweening.ShortcutExtensions+<>c\_\_DisplayClass44\_0.\<DOScale>b\_\_1 (UnityEngine.Vector3 x) \[0x00000] in D:\DG\\\_Develop\\\_\_UNITY\_ASSETS\\\_Demigiant\\\_\_DOTween\\\_DOTween.Assembly\DOTween\ShortcutExtensions.cs:621 at DG.Tweening.Plugins.Vector3Plugin.EvaluateAndApply (DG.Tweening.Plugins.Options.VectorOptions options, DG.Tweening.Tween t, System.Boolean isRelative, DG.Tweening.Core.DOGetter`1\[T] getter, DG.Tweening.Core.DOSetter`1\[T] setter, System.Single elapsed, UnityEngine.Vector3 startValue, UnityEngine.Vector3 changeValue, System.Single duration, System.Boolean usingInversePosition, System.Int32 newCompletedSteps, DG.Tweening.Core.Enums.UpdateNotice updateNotice) \[0x0022b] in D:\DG\\\_Develop\\\_\_UNITY\_ASSETS\\\_Demigiant\\\_\_DOTween\\\_DOTween.Assembly\DOTween\Plugins\Vector3Plugin.cs:159 at DG.Tweening.Core.TweenerCore`3\[T1,T2,TPlugOptions].ApplyTween (System.Single prevPosition, System.Int32 prevCompletedLoops, System.Int32 newCompletedSteps, System.Boolean useInversePosition, DG.Tweening.Core.Enums.UpdateMode updateMode, DG.Tweening.Core.Enums.UpdateNotice updateNotice) \[0x00030] in D:\DG\\\_Develop\\\_\_UNITY\_ASSETS\\\_Demigiant\\\_\_DOTween\\\_DOTween.Assembly\DOTween\Core\TweenerCore.cs:261 UnityEngine.Debug:LogWarning (object) DG.Tweening.Core.Debugger:LogSafeModeCapturedError (object,DG.Tweening.Tween) (at D:/DG/\_Develop/\_\_UNITY\_ASSETS/\_Demigiant/\_\_DOTween/\_DOTween.Assembly/DOTween/Core/Debugger.cs:61) DG.Tweening.Core.TweenerCore`3\<UnityEngine.Vector3, UnityEngine.Vector3, DG.Tweening.Plugins.Options.VectorOptions>:ApplyTween (single,int,int,bool,DG.Tweening.Core.Enums.UpdateMode,DG.Tweening.Core.Enums.UpdateNotice) (at D:/DG/\_Develop/\_\_UNITY\_ASSETS/\_Demigiant/\_\_DOTween/\_DOTween.Assembly/DOTween/Core/TweenerCore.cs:265) DG.Tweening.Tween:DoGoto (DG.Tweening.Tween,single,int,DG.Tweening.Core.Enums.UpdateMode) (at D:/DG/\_Develop/\_\_UNITY\_ASSETS/\_Demigiant/\_\_DOTween/\_DOTween.Assembly/DOTween/Tween.cs:266) DG.Tweening.Core.TweenManager:Update (DG.Tweening.Tween,single,single,bool) (at D:/DG/\_Develop/\_\_UNITY\_ASSETS/\_Demigiant/\_\_DOTween/\_DOTween.Assembly/DOTween/Core/TweenManager.cs:569) DG.Tweening.Core.TweenManager:Update (DG.Tweening.UpdateType,single,single) (at D:/DG/\_Develop/\_\_UNITY\_ASSETS/\_Demigiant/\_\_DOTween/\_DOTween.Assembly/DOTween/Core/TweenManager.cs:417) DG.Tweening.Core.DOTweenComponent:Update () (at D:/DG/\_Develop/\_\_UNITY\_ASSETS/\_Demigiant/\_\_DOTween/\_DOTween.Assembly/DOTween/Core/DOTweenComponent.cs:75) jamas me dejo de salir este error. pense que habia echo algo mal, borre todo el codigo que escribi y copie el del profe sigo con este error y no hay nadie que responda estos msj