|
If I store a Touch in one update, am I not supposed to get the updated data from it the next update? Doing something like this:
I expected the log to be updated with the Touch's position if I dragged around my finger. But instead I only get the initial touch position. Is there a way to store something like this so I don't need to loop through fingerIds every time?
(comments are locked)
|
|
The problem is simply that your if-statement is only checking for TouchPhase.Began. This will only be true the first frame. After that, your variable myTouch is not getting updated. So is the only solution to store fingerId of the Touch gotten from the GetTouch within the TouchPhase.Began statement, and then use GetTouch every update and check if the Touch returned has the same fingerId as the stored one?
Dec 09 '10 at 07:15 PM
Mrten
That might work, but if you aren't writing multitouch behavior then you probably don't need to bother. Just handle the cases where the phase is Cancelled or Ended. (And, if there is suddenly more than 1 touch then treat that as a cancel as well, or walk the array looking for the finger-id you were working with before.) My game only needs single-touches and I have never had to do anything with finger-ids.
Dec 09 '10 at 11:30 PM
Bampf
Yeah, the whole reason I want to store away a Touch is because I need multitouch. The reference manual for Input seemed to suggest that this would be possible, and I felt that would be a much more convenient method than constantly looping through the array. Well, I guess I'm stuck with redundancy!
Dec 10 '10 at 09:56 AM
Mrten
(comments are locked)
|
|
TouchPhase.Moved what u need.. it sends new position if u hold and drag on screen.With begin u only get the initial position when u out your finger then for dragging u have to use TouchPhase.Moved also u can get the last position that u finished swiping with TouchPhase.Ended
(comments are locked)
|
|
Touch is a struct which is a value type. This means that it copies the values instead of having a reference or "link" to the Touch. So on frame one if you save the Touch to a variable it copies the values at that time and saves them but has no idea what that Touch is up to anytime after that. You have to keep updating it every frame. So save the finger ID of the touch so you can find the input that you want in future frames. Hope that helps.
(comments are locked)
|
