- Home /
Creating a matrix or some sort.
Sorry if the title doesnt match. I couldnt really think of what to write for the title.
I'm working on creating a bounding box or a matrix using array to detect the position of the user's finger. My idea of it is setting a bounding box made with array and detect whether the finger is within the range of the bounding box. Is there any way to go about it?
[SOLVED]
I figured out that was such a method called Rect.Contains. This did what I wanted.
var rect = Rect(x,y,width,height);
if(rect.Contains(touch) { }
The var rect creates a box and the if statement checks that if the touch is within the box.
However, I have a problem of putting it in ArrayList. It gives me the following error: The type 'System.Collections.ArrayList' does not have a visible constructor. I don't face this problem when I put in Array though.
Would be great if someone can explain why this error may have occured.
Answer by ckfinite · Nov 30, 2010 at 02:36 AM
What would be best is to simply see if the finger is between two Vector2s like this
if ((touch.position - topLeftPos).SqrMagnitude() > 0 && (touch.position - lowerRightPos).SqrMagnitude() < 0) {
//do stuff with touch
}
i managed to find another way to get to what i wanted. posted my codes in. thanks for ur help anyway =)
As for your second question, use List. Basically it is saying that it does not have a constructor for what you are trying to initialize it with. Can you post the code? Anyways, List is the more used construct in C#.
Your answer
Follow this Question
Related Questions
Random NullReferenceException 0 Answers
Mobile game Player follow finger input problem (C#) 2 Answers
audio array touch selection 1 Answer
object falow finger problem ? 4 Answers
Can you use a Vectrosity points array with iTween? 0 Answers