using UnityEngine;
using System.Collections;

public class FoodSnake : MonoBehaviour {
public int yLimit = 30;
public int xLimit = 22;
public GameObject SSFood;
// Use this for initialization
void Start ()
{
InvokeRepeating("Food", 1, 4);
}

// Update is called once per frame
void Food()
{
int x = Random.Range(-xLimit,xLimit);
int y = Random.Range(-yLimit,yLimit);

//Quaternion.identity=旋转的角度0.0.0.0 SSFood是这个cube   new Vector2(x, y) 物体出现的位置

Instantiate(SSFood, new Vector2(x, y), Quaternion.identity);
}
void Update ()
{

}
}

posted on 2016-11-27 14:21  春天里的麦子  阅读(244)  评论(0编辑  收藏  举报