首页 > 其他 > 详细

《学习创建一个随机产生的物体的代码》

时间:2016-11-27 16:41:18      阅读:150      评论:0      收藏:0      [点我收藏+]

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 ()
{

}
}

《学习创建一个随机产生的物体的代码》

原文:http://www.cnblogs.com/ylllove/p/6106433.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!