using UnityEngine using System Collections public class Arrow MonoBeha

 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
using UnityEngine;
using System.Collections;
public class Arrow : MonoBehaviour
{
void Start()
{
rigidbody2D.fixedAngle = true;
SliderJoint2D slider = GetComponent<SliderJoint2D>();
slider.collideConnected = true;
slider.connectedAnchor = new Vector2 (transform.position.x , transform.position.y);
}
void OnTouchMoved(Touch touch)
{
Vector2 Force = new Vector2(touch.deltaPosition.x * 50, 0);
if (Force.x * transform.localScale.x > 0)
rigidbody2D.AddForceAtPosition(Force, Camera.main.ScreenToWorldPoint(touch.position));
}
void OnTouchBegan()
{
GetComponent<SpriteRenderer>().color = new Color32(100, 100, 100, 255);
}
void OnTouchEnded()
{
GetComponent<SpriteRenderer>().color = new Color32(255, 255, 255, 255);
}
}