UNITY | PROJECT | SPACE SHOOTER 2D | 11. Timer UI & GameTitle

2
Importing Timer UI

 

3
Adding Timer UI Image
  • Add an UI Image for Timer
    • Add Timer UI to “Source Image”
      • Press “Set Native Size”

 

4
Adding Timer Text
  • Add a UI Text for Timer Counter
    • Add Text for the default value
    • Change Font Style to “Bold”, Font Size to “30”
    • Add “Timer Controller” Script
    • Change Anchor to “Top-Right”

 

5
“TimerController” Script
  • Get the Reference for TimeUI
  • Claim “startTime”, “ellapsedTime” and “startCounter” as flag
  • Claim “minutes” and “seconds”
  • In “Start()” method
    • Set the flag to false
    • Get the Component of “Text”
  • Create a Function, “StartTimeCounter()” to start the Timer
    • Get the current time when the timer is started
    • Set the Flag to True
  • Create a Function, “StopTimeCounter()” to stop the Timer
    • Set the Flag to False
  • In “Update()” method,
    • if the flag is True (when it is on)
      • Get the Elapsed Time by subtracting “startTime” from the Current Time in this very frame
      • Get the minute and second based on the Elapsed Time
      • Update the Timer UI by accessing the Text Property with String.Format
6.1
“GameManager” Script
  • Add codes to Start and Stop the Timer
    • Get the Component of “TimerCounter” Class to use “StartTimeCounter()” and “StopTimeCounter()”
6.2
“Timer” Working

 

7.1
Importing “GameTitle”
  • Add “Game Title” image on the Hierarchy
    • Set the sorting layer to “Effect”

 

8
“GameManager” Script
  • Add Codes to Turn on & off Game Title by using “GameObject.SetActive()”
    • When Case “Opening”,
      • Set Game Title On
    • When Case “GamePlay”
      • Set Game Title Off
7.2
“GameTitle” Working

WEEK3 |UNITY 2D | Timer part.2

4
Timer
5
Timer | Fields | Bool
6
Timer | Properties | set
7
Timer | Methods | Update() | Run()
8
Timer Test | Start() | gameObject.Addcomponent() | Time.time
9
Timer | AddComponent<>() | Result

WEEK3 |UNITY 2D | Selection, Timer Part.1

Boolean Expression

  • Data Type – “bool”
  • evaluates “True” or “False
  • helps us with Selection Control Structure
    • lets us make decisions about which code to execute
      • Example 1) Movement Direction based on user input
      • Example 2) Whether or not an enemy drops loot
      • Example 3) Whether or not a player has leveled up
      • Example 4)
  • Logical Operators
    • And : “&&
    • Or : “| |”
    • Not : “!”
  • Relational Operators
    • ==
    • !=
    • <
    • <=
    • >
    • >=
6
Jumper.cs
7
Timer Logic