Exemple #1
0
            // -----------------
            public int HitTest(List <TouchControl> controlList, Vector2 screenPos, Camera cam, int maxHits = 8, float fingerRadPx = 0, TouchControlFilterFunc filter = null)
            {
                if (maxHits < 1)
                {
                    maxHits = 1;
                }

                this.Clear();
                this.EnsureCapacity(maxHits);

                for (int ci = 0; ci < controlList.Count; ++ci)
                {
                    TouchControl c = controlList[ci];
                    if ((c == null) || ((filter != null) && !filter(c)))
                    {
                        continue;
                    }

                    if (!c.HitTest(screenPos, cam, fingerRadPx, this.tempHit))
                    {
                        continue;
                    }

                    int insertPos = -1;
                    for (int ti = 0; ti < this.GetList().Count; ++ti)
                    {
                        if (this.tempHit.IsHigherThan(this.GetList()[ti]))
                        {
                            insertPos = ti;
                            break;
                        }
                    }

                    // Add new hit to the list...

                    if (this.GetUsedCount() < maxHits)
                    {
                        this.GetNewObject(insertPos).CopyFrom(this.tempHit);
                    }

                    // If the list is fulll recycle the last hit...

                    else if (insertPos >= 0)
                    {
                        Hit lastHit = this.GetList()[maxHits - 1];
                        this.GetList().RemoveAt(maxHits - 1);
                        this.GetList().Insert(insertPos, lastHit);

                        lastHit.CopyFrom(this.tempHit);
                    }
                }


                return(this.GetUsedCount());
            }
Exemple #2
0
            // ------------------
            public bool HitTestAny(List <TouchControl> controlList, Vector2 screenPos, Camera cam, float fingerRadPx = 0, TouchControlFilterFunc filter = null)
            {
                this.EnsureCapacity(1);
                this.Clear();

                for (int i = 0; i < controlList.Count; ++i)
                {
                    TouchControl c = controlList[i];
                    if ((c == null) || ((filter != null) && !filter(c)))
                    {
                        continue;
                    }

                    if (c.HitTest(screenPos, cam, fingerRadPx, this.tempHit))
                    {
                        this.GetNewObject().CopyFrom(this.tempHit);
                        return(true);
                    }
                }

                return(false);
            }