纳金网

标题: Android touch [打印本页]

作者: 奔跑的小兔    时间: 2012-4-19 14:01
标题: Android touch
var touch : Touch;

var tCount : GUIText;

var tapcount : GUIText;

var touchPhase : TouchPhase[];

var taps : int[];
function Start () {

for (var j = 0; j < 4; ++j)

  touchPhase[j] = TouchPhase.Stationary;

}
function OnGUI () {

  

for (var i = 0; i < Input.touchCount; ++i) {

   touch = Input.GetTouch(i);

           GUI.Button(Rect((touch.position.x - 120), (Screen.height - touch.position.y - 35), 90, 20), " " + touch.fingerId + " " + touchPhase);

           

           GUI.Button(Rect((touch.position.x - 120), (Screen.height - touch.position.y - 65), 27, 20), " " + taps);

    }



if (GUI.Button(Rect(250, 10, 200, 30), "multiTouch.enabled: " + Input.multiTouchEnabled))

  Input.multiTouchEnabled = !Input.multiTouchEnabled;

  

}
function FixedUpdate () {

  tCount.text = "touchCount: " + Input.touchCount;

  

  for (var i = 0; i < Input.touchCount; ++i) {

   touch = Input.GetTouch(i);

   touchPhase = touch.phase;

   taps = touch.tapCount;

   tapcount.text = "tapCount: " + touch.tapCount;

  }

  

}




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