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; }
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); }
public virtual AsTouch getTouch(AsDisplayObject target, String phase) { getTouches(target, phase, sTouches); if (sTouches.getLength() != 0) { AsTouch touch = sTouches[0]; sTouches.setLength(0); return(touch); } else { return(null); } }
public virtual AsVector <AsTouch> getTouches(AsDisplayObject target, String phase, AsVector <AsTouch> result) { if (result == null) { result = new AsVector <AsTouch>(); } AsVector <AsTouch> allTouches = getData() as AsVector <AsTouch>; int numTouches = (int)(allTouches.getLength()); int i = 0; for (; i < numTouches; ++i) { AsTouch touch = allTouches[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) { result.push(touch); } } return(result); }
private void processTouch(int touchID, String phase, float globalX, float globalY, float pressure, float width, float height) { 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); touch.setPressure(pressure); touch.setSize(width, height); 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); }
public AsTouchData(AsTouch touch, AsDisplayObject target) { mTouch = touch; mTarget = target; }