2015-7-4
2015-07-07 23:02
225 查看
using UnityEngine; using System.Collections; public class sjt2 : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { transform.position += new Vector3 (1, 0, 0) * Time.deltaTime; // 物体一直朝向x轴移动 } }
</pre><pre name="code" class="cpp"><pre name="code" class="cpp">using UnityEngine; using System.Collections; public class NewBehaviourScript : MonoBehaviour { //public sjt(float x, float y); // 构造体 Transform tran; // 主界面help // // Debug.Log(); // 打印 // Use this for initialization void Start () { // 执行一次 //Do(); tran = this.gameObject.GetComponent<Transform>(); //float posX = tran.position.x; //tran.position.x = 5; // error tran.position = new Vector3 (0, 0, 0); transform.position = new Vector3 (1, 1, 1); transform.localPosition = new Vector3 (1,1,1); // 界面属性上的position //transform.rotation = new Quaternion (30, 30, 30, 30); transform.localEulerAngles = new Vector3 (0, 30, 0); // 修改 Rotation transform.localScale = new Vector3 (2,2,2); // 局部缩放属性 // this,指脚本 this 是c#的关键词 // gameObject 所挂载的对象 // Component 组件 // Transform 指 泛型 http://baike.baidu.com/link?url=Uuau1uqsT-Ed_tzBB3QdLUnoelxdsCGgIWQICAsvm4ZABqZp8g1JFEmimc0IWXfXys9sVXTSslCyM21mJFNOqa } // void Do(string sjt) // { // int resultNum = num1 / num2; // Debug.Log(resultNum); // print (resultNum); // } // Update is called once per frame void Update ()// 物体所有动的操作都要写到 Update( { //print ("nihao!"); } void OnGui() { GUI.skin.label.fontSize = 100; GUI.Label (new Rect(10, 10, Screen.width, Screen.height), "Hello World"); } }
<pre name="code" class="cpp">using UnityEngine; using System.Collections; public class MainPlayer : MonoBehaviour { float move = 1; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(Input.GetKey(KeyCode.RightArrow)) { //this.transform.Translate (new Vector2(move, 0)); this.gameObject.transform.position += new Vector3(1,0,0)*move *Time.deltaTime; } } }
相关文章推荐
- udp服务端和客户端程序示例
- 2015070709 - 挑战更换
- 【android Studio】零git知识、零脚本命令,即刻体验git版本管理魅力!
- shell中${}的妙用
- poj1573 模拟
- linux中描述符和标准IO流对文件的基本操作
- Spring学习(15)--- 基于Java类的配置Bean 之 @Bean & @Scope 注解
- hdu 2571 命运
- js的数组ECMAScript 5加入的方法(二)
- hdoj 1083 Courses【匈牙利算法】
- 通过IF({1,0}和VLOOKUP函数实现Excel的双条件多条件查找
- 每天一个linux命令(10):cat 命令
- 2015-7-3,鼠标左键下下,或者空格按下
- 【麦可网】Cocos2d-X跨平台游戏开发学习笔记---第二十七课:Cocos2D-X物理引擎之chipmunk
- switch语句:适用于一个条件有多个分支的情况---分支语句
- JSP详解
- 程序员笔试经典题目拾粹001
- vs 调试
- 2015070708 - 修正笔记
- 一个适用于层级目录结构的makefile模版