Beispiel #1
0
        private void processTap(AsTouch touch)
        {
            AsTouch            nearbyTap = null;
            float              minSqDist = MULTITAP_DISTANCE * MULTITAP_DISTANCE;
            AsVector <AsTouch> __taps_   = mLastTaps;

            if (__taps_ != null)
            {
                foreach (AsTouch tap in __taps_)
                {
                    float sqDist = AsMath.pow(tap.getGlobalX() - touch.getGlobalX(), 2) + AsMath.pow(tap.getGlobalY() - touch.getGlobalY(), 2);
                    if (sqDist <= minSqDist)
                    {
                        nearbyTap = tap;
                        break;
                    }
                }
            }
            if (nearbyTap != null)
            {
                touch.setTapCount(nearbyTap.getTapCount() + 1);
                mLastTaps.splice(mLastTaps.indexOf(nearbyTap), (uint)(1));
            }
            else
            {
                touch.setTapCount(1);
            }
            mLastTaps.push(touch.clone());
        }
 public virtual AsTouch clone()
 {
     AsTouch clone = new AsTouch(mID, mGlobalX, mGlobalY, mPhase, mTarget);
     clone.mPreviousGlobalX = mPreviousGlobalX;
     clone.mPreviousGlobalY = mPreviousGlobalY;
     clone.mTapCount = mTapCount;
     clone.mTimestamp = mTimestamp;
     return clone;
 }
Beispiel #3
0
        public virtual AsTouch clone()
        {
            AsTouch clone = new AsTouch(mID, mGlobalX, mGlobalY, mPhase, mTarget);

            clone.mPreviousGlobalX = mPreviousGlobalX;
            clone.mPreviousGlobalY = mPreviousGlobalY;
            clone.mTapCount        = mTapCount;
            clone.mTimestamp       = mTimestamp;
            return(clone);
        }
Beispiel #4
0
        private void addCurrentTouch(AsTouch touch)
        {
            int i = (int)(mCurrentTouches.getLength() - 1);

            for (; i >= 0; --i)
            {
                if (mCurrentTouches[i].getId() == touch.getId())
                {
                    mCurrentTouches.splice(i, (uint)(1));
                }
            }
            mCurrentTouches.push(touch);
        }
        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);
        }
Beispiel #6
0
        private void processTouch(int touchID, String phase, float globalX, float globalY)
        {
            AsPoint position = new AsPoint(globalX, globalY);
            AsTouch touch    = getCurrentTouch(touchID);

            if (touch == null)
            {
                touch = new AsTouch(touchID, globalX, globalY, phase, null);
                addCurrentTouch(touch);
            }
            touch.setPosition(globalX, globalY);
            touch.setPhase(phase);
            touch.setTimestamp(mElapsedTime + mOffsetTime);
            if (phase == AsTouchPhase.HOVER || phase == AsTouchPhase.BEGAN)
            {
                touch.setTarget(mStage.hitTest(position, true));
            }
            if (phase == AsTouchPhase.BEGAN)
            {
                processTap(touch);
            }
        }
 public AsTouchData(AsTouch touch, AsDisplayObject target)
 {
     this.touch = touch;
     this.target = target;
 }
 private void processTouch(int touchID, String phase, float globalX, float globalY)
 {
     AsPoint position = new AsPoint(globalX, globalY);
     AsTouch touch = getCurrentTouch(touchID);
     if((touch == null))
     {
         touch = new AsTouch(touchID, globalX, globalY, phase, null);
         addCurrentTouch(touch);
     }
     touch.setPosition(globalX, globalY);
     touch.setPhase(phase);
     touch.setTimestamp((mElapsedTime + mOffsetTime));
     if(((phase == AsTouchPhase.HOVER) || (phase == AsTouchPhase.BEGAN)))
     {
         touch.setTarget(mStage.hitTest(position, true));
     }
     if((phase == AsTouchPhase.BEGAN))
     {
         processTap(touch);
     }
 }
 private void processTap(AsTouch touch)
 {
     AsTouch nearbyTap = null;
     float minSqDist = (MULTITAP_DISTANCE * MULTITAP_DISTANCE);
     AsVector<AsTouch> __taps_ = mLastTaps;
     if (__taps_ != null)
     {
         foreach (AsTouch tap in __taps_)
         {
             float sqDist = (AsMath.pow((tap.getGlobalX() - touch.getGlobalX()), 2) + AsMath.pow((tap.getGlobalY() - touch.getGlobalY()), 2));
             if((sqDist <= minSqDist))
             {
                 nearbyTap = tap;
                 break;
             }
         }
     }
     if(nearbyTap != null)
     {
         touch.setTapCount((nearbyTap.getTapCount() + 1));
         mLastTaps.splice(mLastTaps.indexOf(nearbyTap), (uint)(1));
     }
     else
     {
         touch.setTapCount(1);
     }
     mLastTaps.push(touch.clone());
 }
 private void addCurrentTouch(AsTouch touch)
 {
     int i = (int)((mCurrentTouches.getLength() - 1));
     for (; (i >= 0); --i)
     {
         if((mCurrentTouches[i].getId() == touch.getId()))
         {
             mCurrentTouches.splice(i, (uint)(1));
         }
     }
     mCurrentTouches.push(touch);
 }
Beispiel #11
0
 public AsTouchData(AsTouch touch, AsDisplayObject target)
 {
     this.touch  = touch;
     this.target = target;
 }
Beispiel #12
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;
            }
        }