2015-7-4

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;

		}



	}
}


 




                
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值