[英]how to get the first touch point and the second touch point on windows phone 8?
[英]How to make my Rectangle move in Windows Phone 7 using Touch point?
我遇到問題,如何在Windows Phone 7中使用觸摸輸入向上或向下移動簡單的矩形。我設法向上移動矩形並進行點擊測試,但是如何知道觸摸輸入是否下降?
我做了一個hitBox,這是我的代碼。
Rectangle hitbox =
new Rectangle(32,
GraphicsDevice.Viewport.Bounds.Height / 2 - 64,
32,
128);
foreach (TouchLocation location in TouchPanel.GetState())
{
hitbox = new Rectangle((int)blueBar.X, (int)blueBar.Y, 32, 128);
if (hitbox.Contains((int)location.Position.X, (int)location.Position.Y))
{
Debug.WriteLine("We’re hit!");
blueBar.Y -= 10;
}
}
與其嘗試使用矩形來測試用戶的觸摸,不如嘗試以下方法:
http://codecube.net/2010/03/approximating-touch-points/
這個想法是,您只需激活“最接近” UI元素到接觸點即可...這樣,您就不必擔心混亂的碰撞檢測:-)
除此之外,這是我寫的一篇有關使用接觸點在屏幕上平滑移動精靈的文章:
http://codecube.net/2010/04/smooth-control-with-touch/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.