-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatMove.js
More file actions
48 lines (35 loc) · 925 Bytes
/
Copy pathmatMove.js
File metadata and controls
48 lines (35 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma strict
private var matSlide : Rigidbody2D;
var speed = 2.0;
private var movement : Vector2;
var time = 0.0;
private var spawnPosiiton : Vector2;
private var count = 0;
var countText : UI.Text;
var winText : UI.Text;
function Start () {
matSlide = GetComponent.<Rigidbody2D>();
count = 0;
winText.text = "";
//InvokeRepeating("Spawn",spawnTime,spawnTime);
}
function Update () {
time += Time.deltaTime;
var moveHorizontal = Input.GetAxis("Horizontal");
//var moveVertical = Input.GetAxis("Vertical");
movement = new Vector2(moveHorizontal,0); //moveVertical);
matSlide.AddForce(movement * speed);
}
function OnTriggerEnter2D(other:Collider2D){
if(other.gameObject.tag == "ball_large"){
Destroy(other.gameObject);
count = count + 1;
SetCountText();
}
}
function SetCountText(){
countText.text = "Count:" + count.ToString();
if(count >= 20){
Application.LoadLevel("level2");
}
}