public virtual AsVector <AsTouch> getTouches(AsDisplayObject target, String phase)
        {
            AsVector <AsTouch> touchesFound = new AsVector <AsTouch>();
            int numTouches = (int)(mTouches.getLength());
            int i          = 0;

            for (; i < numTouches; ++i)
            {
                AsTouch touch         = mTouches[i];
                bool    correctTarget = (touch.getTarget() == target) || ((target is AsDisplayObjectContainer) && target as AsDisplayObjectContainer.contains(touch.getTarget()));
                bool    correctPhase  = phase == null || phase == touch.getPhase();
                if (correctTarget && correctPhase)
                {
                    touchesFound.push(touch);
                }
            }
            return(touchesFound);
        }
Example #2
0
        public virtual void advanceTime(float passedTime)
        {
            int     i     = 0;
            AsTouch touch = null;

            mElapsedTime = mElapsedTime + passedTime;
            mOffsetTime  = 0.0f;
            if (mLastTaps.getLength() > 0)
            {
                for (i = (int)(mLastTaps.getLength() - 1); i >= 0; --i)
                {
                    if (mElapsedTime - mLastTaps[i].getTimestamp() > MULTITAP_TIME)
                    {
                        mLastTaps.splice(i, (uint)(1));
                    }
                }
            }
            while (mQueue.getLength() > 0)
            {
                sProcessedTouchIDs.setLength(0);
                sHoveringTouchData.setLength(0);
                AsVector <AsTouch> __currentTouchs_ = mCurrentTouches;
                if (__currentTouchs_ != null)
                {
                    foreach (AsTouch currentTouch in __currentTouchs_)
                    {
                        if (currentTouch.getPhase() == AsTouchPhase.BEGAN || currentTouch.getPhase() == AsTouchPhase.MOVED)
                        {
                            currentTouch.setPhase(AsTouchPhase.STATIONARY);
                        }
                    }
                }
                AsVector <AsTouchData> __touchDatas_ = sHoveringTouchData;
                if (__touchDatas_ != null)
                {
                    foreach (AsTouchData touchData in __touchDatas_)
                    {
                        if (touchData.touch.getTarget() != touchData.target)
                        {
                            touchData.target.dispatchEvent(new AsTouchEvent(AsTouchEvent.TOUCH, mCurrentTouches, mShiftDown, mCtrlDown));
                        }
                    }
                }
                AsVector <int> __touchIDs_ = sProcessedTouchIDs;
                if (__touchIDs_ != null)
                {
                    foreach (int touchID in __touchIDs_)
                    {
                        touch = getCurrentTouch(touchID);
                        if (touch.getTarget() != null)
                        {
                            touch.getTarget().dispatchEvent(new AsTouchEvent(AsTouchEvent.TOUCH, mCurrentTouches, mShiftDown, mCtrlDown));
                        }
                    }
                }
                for (i = (int)(mCurrentTouches.getLength() - 1); i >= 0; --i)
                {
                    if (mCurrentTouches[i].getPhase() == AsTouchPhase.ENDED)
                    {
                        mCurrentTouches.splice(i, (uint)(1));
                    }
                }
                mOffsetTime = mOffsetTime + 0.00001f;
            }
        }