StartBall









How do I use Start Ball
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: BallScript.cs Copy
41     public void StartBall()
42     {
43         transform.position = InitialLocation;
44         GetComponent().velocity = new Vector2(Random.Range(-3.0f, 3.0f), SpeedY);
45     }
File name: GameManager.cs Copy
27     void Update()
28     {
29         switch (CurrentGameState)
30         {
31             case GameState.Start:
32                 if (InputTaken())
33                 {
34                     statusText.text = string.Format("Lives: {0} Score: {1}", Lives, Score);
35                     CurrentGameState = GameState.Playing;
36                     Ball.StartBall();
37                 }
38                 break;
39             case GameState.Playing:
40                 break;
41             case GameState.Won:
42                 if (InputTaken())
43                 {
44                     Restart();
45                     Ball.StartBall();
46                     statusText.text = string.Format("Lives: {0} Score: {1}", Lives, Score);
47                     CurrentGameState = GameState.Playing;
48                 }
49                 break;
50             case GameState.LostALife:
51                 if (InputTaken())
52                 {
53                     Ball.StartBall();
54                     statusText.text = string.Format("Lives: {0} Score: {1}", Lives, Score);
55                     CurrentGameState = GameState.Playing;
56                 }
57                 break;
58             case GameState.LostAllLives:
59                 if (InputTaken())
60                 {
61                     Restart();
62                     Ball.StartBall();
63                     statusText.text = string.Format("Lives: {0} Score: {1}", Lives, Score);
64                     CurrentGameState = GameState.Playing;
65                 }
66                 break;
67             default:
68                 break;
69         }
70     }

StartBall 114 lượt xem

Gõ tìm kiếm nhanh...