标签:cto tor his 脚本 第一个 direction wsad for upd
public class MoveSnake : MonoBehaviour {
Vector2 direction = Vector2.up;
// Use this for initialization
void Start ()
{
InvokeRepeating("Move", 0.5f, 0.5f);
}
// Update is called once per frame
void Update ()
{
//开始通过WSAD操作物体的移动
if (Input.GetKey(KeyCode.W))
{
direction = Vector2.up;
}
if (Input.GetKey(KeyCode.S))
{
direction = Vector2.down;
}
if (Input.GetKey(KeyCode.A))
{
direction = Vector2.left;
}
if (Input.GetKey(KeyCode.D))
{
direction = Vector2.right;
}
}
void Move()
{
transform.Translate(direction);
}
标签:cto tor his 脚本 第一个 direction wsad for upd
原文地址:http://www.cnblogs.com/ylllove/p/6106338.html