首页 > 编程语言 > 详细

Unity-3d Day03 做了一个吃粑粑豆的小游戏 hiahia~~

时间:2015-03-26 01:01:49      阅读:188      评论:0      收藏:0      [点我收藏+]

红色球的脚本:

using UnityEngine;
using System.Collections;

public class PlayScript : MonoBehaviour {
    public GameObject sphere;
    // Use this for initialization
    void Start () {
        //创建50个粑粑豆
        for (int i = 0; i < 50; i++)
        {
            print(i);
            int x = Random.Range(-4, 5);
            int y = Random.Range(-4, 5);
            sphere = Instantiate(sphere, new Vector3(x, 0.5f, y), Quaternion.identity) as GameObject;
        }
    }
    
    // Update is called once per frame
    void Update () {
        float horizontal = Input.GetAxis("Horizontal");
        float vertical = Input.GetAxis("Vertical");
        transform.position += Vector3.forward * vertical/4;
        transform.position += Vector3.right * horizontal/4;
        
    }
}

粑粑豆脚本:

using UnityEngine;
using System.Collections;

public class BeanScript : MonoBehaviour {
    
    // Use this for initialization
    void Start () {
        
    }
    void OnCollisionEnter(Collision collision)
    {
        Destroy(gameObject);
    }
    // Update is called once per frame
    void Update () {
    
    }
    
}

  效果图:

技术分享技术分享技术分享

 

hiahaihia  是不是有点屌  好了  写完收工  睡觉去喽

Unity-3d Day03 做了一个吃粑粑豆的小游戏 hiahia~~

原文:http://www.cnblogs.com/little-sun/p/4367296.html

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