Loading...

Creating Success and Failed Scenes

View: 168    Dowload: 0   Comment: 0   Post by: daii   Category: Mobile applications   Fields: Game - Entertainment

Download  creating-success-and-failed.zip (8.60 MB)

You need to Sign In to download the file creating-success-and-failed.zip
If you do not have an account then Sign up for free here

Creating the Success Scene

This scene will indicate if you successfully completed a level then you can proceed to the next level. First thing to do is to create a new Scene called Success. Then create a UI Image, just like what you did on the gameplay UI locate the sprite in the Sprites folder then attach it to Source Image. Rename it as Background and set its components values a shown below.
tut38

Create now these several UI objects as follow (Text and 2 Buttons), and set each components as shown below.

Text
tut39

Buttons
tut40

tut41

After that create a panel and set its component same as the image below.
tut42

Then add a UI Text as a child of the panel

Score
tut43

Child of the Score UI Text
tut44

Now that the UI Elements are ready we will now need to create Controllers to handle the event triggers. To do that create a new GameObject called it Next Level Controller. Then create a C# script save it inside the Game Controllers folder as NextLevelController.

Import these important modules first:


 
  1. using UnityEngine.UI;
  2. using UnityEngine.SceneManagement;

Write these certain variables


 
  1. public Text scoreText;
  2. private int score;

 

 
 

After that write the rest of the code inside the class


 
  1. // Use this for initialization
  2. void Start () {
  3. InitializeVariables ();
  4. if (GameController.instance != null && MusicController.instance != null) {
  5. if(GameController.instance.isMusicOn){
  6. MusicController.instance.StopAllSound ();
  7. MusicController.instance.PlaySuccessSound ();
  8. }
  9. }
  10. }
  11.  
  12. void InitializeVariables(){
  13. score = GameController.instance.currentScore;
  14. scoreText.text = score.ToString ();
  15. }
  16.  
  17. public void NextButton(){
  18. SceneManager.LoadScene ("Gameplay");
  19. }
  20.  
  21. public void ExitButton(){
  22. SceneManager.LoadScene ("Main Menu");
  23. }

Attach the script to the GameObject inspector then drag and assign each corresponding component to script inspectors.
tut45

Note: Make sure to attach the Script to each Buttons Runtime script.

Creating the Failed Scene

This scene will indicate if you failed a level then a prompt will indicate that can try again. First thing to do is to create a new Scene and save it as Failed. To make this easier just copy the Canvas UI and EventSystem, then paste it the Hierarchy of the Failed Scene.

Just change Success Text to Fail Text then create a new GameObject called it Restart Controller. After that create a C# script called RestartController.

Import these important modules first:


 
  1. using UnityEngine.UI;
  2. using UnityEngine.SceneManagement;

Write these certain variables


 
  1. public Text scoreText;
  2. private int score;

After that write the rest of the code inside the class


 
  1. // Use this for initialization
  2. void Start () {
  3. InitializeVariables ();
  4. if(GameController.instance != null && MusicController.instance != null){
  5. if(GameController.instance.isMusicOn){
  6. MusicController.instance.StopAllSound ();
  7. MusicController.instance.PlayFailedSound ();
  8. }
  9. }
  10. }
  11.  
  12. void InitializeVariables(){
  13. score = GameController.instance.currentScore;
  14. scoreText.text = score.ToString ();
  15. }
  16.  
  17. public void RestartButton(){
  18. SceneManager.LoadScene ("Gameplay");
  19. }
  20.  
  21. public void ExitButton(){
  22. SceneManager.LoadScene ("Main Menu");
  23. }

Attach the script to the GameObject inspector then drag and assign each corresponding component to script inspectors.
tut46

Note: Make sure to attach the Script to each Buttons Runtime script.

Creating Success and Failed Scenes

Creating the Success Scene This scene will indicate if you successfully completed a level then you can proceed to the next level. First thing to do is to create a new Scene called Success . Then create a UI Image, just like what you did on the gameplay UI locate the sprite in the Sprites folder then attach it to Source Image . Rename it as Background and set its components values a shown below...

Posted on 27-02-2018 

Comment:

To comment you must be logged in members.

Files with category

  • Android - Simple Image Capture

    Android - Simple Image Capture

    View: 589    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    Learn on how to create a Simple Image Capture using Android. This simple application can be used to any system that needed the information about the location of the user. The android is an open source operating system it's free and user friendly to...

  • Android - Simple Video Player

    Android - Simple Video Player

    View: 441    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    Learn on how to create a Simple Video Player using Android. This simple application can be use in viewing some videos. The android is an open source operating system it's free and user friendly to mobile developers. Android is available to any...

  • An Experience about Using Webview in Android Studio 3.0

    An Experience about Using Webview in Android Studio 3.0

    View: 221    Download: 0   Comment: 0

    Category: Android     Fields: Other

    I am blogging on ngocminhtran.com (using WordPress platform). Like most websites, I want to write an Android application to help viewers have a lot of great experiences with my blog.

  • Android - Simple Sending SMS

    Android - Simple Sending SMS

    View: 502    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    Learn on how to create a Simple Sending SMS using Android. This tutorial is only an example for sending an SMS, it does not contain the receiving message yet. Android is a mobile operating system developed by Google. It used in several gadget like...

  • Bomb Explode! (An Android App Strategy Game)

    Bomb Explode! (An Android App Strategy Game)

    View: 453    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    This android app named Bomb Explode! is a capstone project that I made for a particular school. BOMB EXPLODE! is a Human Versus Computer strategy game. The objective is to eliminate the opponent by blowing up their BOMBS. Each player takes a turn by...

  • GIS App for Flood-Prone and Disease Affected Areas

    GIS App for Flood-Prone and Disease Affected Areas

    View: 451    Download: 1   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    GIS App for Flood-Prone and Disease Affected Areas is one of the capstone project that I have created in a particular school. Features of the application: - Geographic Map - GIS - Flood Prone Map - Urban Map - Search a particular area - Has SQLite...

  • NSO Demographic Application

    NSO Demographic Application

    View: 492    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    This app is entitled NSO Demographic Application that was one of the capstone project/thesis project that I made for a particular school. This app features to provide a demographic survey of the National Statistics Office that will send to the...

  • HandEBook: An IT Portable Book Application

    HandEBook: An IT Portable Book Application

    View: 464    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    This is an android mobile application entitled HandEBook: An IT Portable Book Application was one one of the capstone project that I have made in our clients at Cotabato. We used the Basic4Android software for the frontend and SQLite for the database...

 
File suggestion for you
Loading...
File top downloads
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd