Touchstate problem
-
2012年3月5日 下午 04:27
ich habe die Folgene Methode
public static bool fired; public static bool FireButtonTouch(this TouchCollection touchState) { foreach (TouchLocation location in touchState) { // Right side of the screen if (((location.Position.X > 400) && (location.Position.Y > 0)) && ((location.Position.X < 800) && (location.Position.Y < 480)) && (location.State == TouchLocationState.Pressed)) { return fired = true; } } return fired = false; }diese reagiert kurz gesagt wenn die rechte seite des Bildschirms (landscape) berühert wird.
Das problem ist ich bin darauf angewiesen, dass ich nach TouchLocationState.Pressed frage und nicht nach TouchLocationState.moved.
Nun reagiert aber das Spiel immer nur auf moved, bzw das ergebnis ist iommer ein zustand moved. WIe kann ich das verhindern ?
所有回覆
-
2012年3月11日 下午 04:05版主
Schau Dir mal http://forums.create.msdn.com/forums/t/72630.aspx an, dort wird das Problem recht gut erklärt.
http://patrickgetzmann.wordpress.com/
- 已標示為解答 Robert BreitenhoferMicrosoft Contingent Staff, Owner 2012年3月16日 下午 03:10
-
2012年3月11日 下午 09:16
You would never see a state of Pressed because when you call GetState() the second time we move any touches in the Pressed state to the Moved state.
Du rufst vermutlich zweimal GetState auf...
Arbeitest du nur direkt mit dem Input mit TouchCollection oder auch mit den States? (Tap, DoubleTap, Pinch etc)...
QuickFix:
public static bool pressed= false; public static bool FireButtonTouch(this TouchCollection touchState) { foreach (TouchLocation location in touchState) { // Right side of the screen if (((location.Position.X > 400) && (location.Position.Y > 0)) && ((location.Position.X < 800) && (location.Position.Y < 480)) && (location.State == TouchLocationState.Moved)&& !pressed) { pressed = true;
return fired = true; }
if(location.State == TouchLocationState.Released){
pressed = false;
}
} return fired = false; }
- 已標示為解答 Robert BreitenhoferMicrosoft Contingent Staff, Owner 2012年3月16日 下午 03:10
-
2012年3月16日 下午 03:10擁有者
Hallo Droggel,
Ich gehe davon aus, dass die Antworten Dir weitergeholfen haben.
Solltest Du noch "Rückfragen" dazu haben, so gib uns bitte Bescheid.Grüße,
RobertRobert Breitenhofer, MICROSOFT

Bitte haben Sie Verständnis dafür, dass im Rahmen dieses Forums, welches auf dem Community-Prinzip „Entwickler helfen Entwickler“ beruht, kein technischer Support geleistet werden kann oder sonst welche garantierten Maßnahmen seitens Microsoft zugesichert werden können.

