GoBall
How do I use Go Ball
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
10 | void GoBall() { | 1 |
22 | Invoke ("GoBall", 2); | 2 |
33 | Invoke ("GoBall", 1); | 3 |
File name: BallControl.cs
Copy
10 void GoBall() {
11 float rand = Random.Range (0, 2);
12 if (rand < 1) {
13 rb2d.AddForce (new Vector2 (20, -15));
14 } else {
15 rb2d.AddForce (new Vector2 (-20, -15));
16 }
17 }
File name: BallControl.cs
Copy
20 void Start () {
21 rb2d = GetComponent
22 Invoke ("GoBall", 2);
23 }
File name: BallControl.cs
Copy
31 void RestartGame() {
32 ResetBall ();
33 Invoke ("GoBall", 1);
34 }
GoBall 179 lượt xem
Gõ tìm kiếm nhanh...