纳金网

标题: 请问哪里错了 为什么点两下按钮 才会开始移动啊 [打印本页]

作者: 雅雅    时间: 2013-6-29 20:12
标题: 请问哪里错了 为什么点两下按钮 才会开始移动啊
var originalPos : Vector3;
private var IsRight;
private var IsLeft;
private var IsUp;
private var IsDown;
function Start()
{
originalPos = transform.position;
}
function Update()
{
if( Input.GetMouseButton(0)&&IsRight )
{
this.transform.Translate(Vector3.right*Time.deltaTime );
}
else if( Input.GetMouseButton(0)&&IsLeft )
{
this.transform.Translate(Vector3.left*Time.deltaTime );
}

else if( Input.GetMouseButton(0)&&IsDown )
{
this.transform.Translate(Vector3.down*Time.deltaTime );

}

else if( Input.GetMouseButton(0)&&IsUp )
{
this.transform.Translate(Vector3.up*Time.deltaTime );
}

else if(Input.GetMouseButtonUp(0))
{
transform.position = originalPos;
}

}
function OnGUI()
{
if (GUI.Button(Rect(15,70,50,30),"Left"))
{
IsRight=!IsRight;
}
if (GUI.Button(Rect(65,70,50,30),"Right"))
{
IsLeft=!IsLeft;
}
if (GUI.Button(Rect(40,100,50,30),"Down"))
{
IsDown=!IsDown;
}
if (GUI.Button(Rect(40,40,50,30),"Up"))
{
IsUp=!IsUp;
}

}




欢迎光临 纳金网 (http://c-www.narkii.com/club/) Powered by Discuz! X2.5