Java Code Examples for org.andengine.input.touch.TouchEvent#INVALID_POINTER_ID

The following examples show how to use org.andengine.input.touch.TouchEvent#INVALID_POINTER_ID . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HoldDetector.java    From tilt-game-android with MIT License 5 votes vote down vote up
protected void triggerOnHoldStarted() {
	this.mTriggering = true;

	if (this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mHoldDetectorListener.onHoldStarted(this, this.mPointerID, this.mHoldX, this.mHoldY);
	}
}
 
Example 2
Source File: ScrollDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
private void triggerOnScrollFinished(final float pDistanceX, final float pDistanceY) {
	this.mTriggering = false;
	
	if(this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mScrollDetectorListener.onScrollFinished(this, this.mPointerID, pDistanceX, pDistanceY);
	}
}
 
Example 3
Source File: ScrollDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
public void reset() {
	if(this.mTriggering) {
		this.mScrollDetectorListener.onScrollFinished(this, this.mPointerID, 0, 0);
	}

	this.mLastX = 0;
	this.mLastY = 0;
	this.mTriggering = false;
	this.mPointerID = TouchEvent.INVALID_POINTER_ID;
}
 
Example 4
Source File: HoldDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
protected void triggerOnHoldFinished(final long pHoldTimeMilliseconds) {
	this.mTriggering = false;

	if(this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mHoldDetectorListener.onHoldFinished(this, pHoldTimeMilliseconds, this.mPointerID, this.mHoldX, this.mHoldY);
	}
}
 
Example 5
Source File: HoldDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
protected void triggerOnHoldStarted() {
	this.mTriggering = true;

	if(this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mHoldDetectorListener.onHoldStarted(this, this.mPointerID, this.mHoldX, this.mHoldY);
	}
}
 
Example 6
Source File: HoldDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
/**
 * When {@link HoldDetector#isHolding()} this method will call through to {@link IHoldDetectorListener#onHoldFinished(HoldDetector, long, int, float, float).
 */
@Override
public void reset() {
	if(this.mTriggering) {
		this.triggerOnHoldFinished(System.currentTimeMillis() - this.mDownTimeMilliseconds);
	}

	this.mTriggering = false;
	this.mMaximumDistanceExceeded = false;
	this.mDownTimeMilliseconds = Long.MIN_VALUE;
	this.mPointerID = TouchEvent.INVALID_POINTER_ID;
}
 
Example 7
Source File: ClickDetector.java    From tilt-game-android with MIT License 5 votes vote down vote up
@Override
public boolean onManagedTouchEvent(final TouchEvent pSceneTouchEvent) {
	switch (pSceneTouchEvent.getAction()) {
		case TouchEvent.ACTION_DOWN:
			this.prepareClick(pSceneTouchEvent);
			return true;
		case TouchEvent.ACTION_MOVE:
			if (this.mPointerID == pSceneTouchEvent.getPointerID()) {
				final long moveTimeMilliseconds = pSceneTouchEvent.getMotionEvent().getEventTime();
				if (moveTimeMilliseconds - this.mDownTimeMilliseconds <= this.mTriggerClickMaximumMilliseconds) {
					return true;
				}
			}
			return false;
		case TouchEvent.ACTION_UP:
		case TouchEvent.ACTION_CANCEL:
			if (this.mPointerID == pSceneTouchEvent.getPointerID()) {
				final long upTimeMilliseconds = pSceneTouchEvent.getMotionEvent().getEventTime();

				boolean handled;
				if (upTimeMilliseconds - this.mDownTimeMilliseconds <= this.mTriggerClickMaximumMilliseconds) {
					this.mDownTimeMilliseconds = Long.MIN_VALUE;
					this.mClickDetectorListener.onClick(this, this.mPointerID, pSceneTouchEvent.getX(), pSceneTouchEvent.getY());
					handled = true;
				} else {
					handled = false;
				}

				this.mPointerID = TouchEvent.INVALID_POINTER_ID;

				return handled;
			} else {
				return false;
			}
		default:
			return false;
	}
}
 
Example 8
Source File: ContinuousHoldDetector.java    From tilt-game-android with MIT License 5 votes vote down vote up
void fireListener() {
	if (this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		final long holdTimeMilliseconds = System.currentTimeMillis() - this.mDownTimeMilliseconds;
		if (holdTimeMilliseconds >= this.mTriggerHoldMinimumMilliseconds) {
			if (this.mTriggering) {
				this.triggerOnHold(holdTimeMilliseconds);
			} else if (!this.mMaximumDistanceExceeded) {
				this.triggerOnHoldStarted();
			}
		}
	}
}
 
Example 9
Source File: ClickDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onManagedTouchEvent(final TouchEvent pSceneTouchEvent) {
	switch(pSceneTouchEvent.getAction()) {
		case TouchEvent.ACTION_DOWN:
			this.prepareClick(pSceneTouchEvent);
			return true;
		case TouchEvent.ACTION_UP:
		case TouchEvent.ACTION_CANCEL:
			if(this.mPointerID == pSceneTouchEvent.getPointerID()) {
				boolean handled = false;
				final long upTimeMilliseconds = pSceneTouchEvent.getMotionEvent().getEventTime();

				if(upTimeMilliseconds - this.mDownTimeMilliseconds <= this.mTriggerClickMaximumMilliseconds) {
					this.mDownTimeMilliseconds = Long.MIN_VALUE;
					this.mClickDetectorListener.onClick(this, pSceneTouchEvent.getPointerID(), pSceneTouchEvent.getX(), pSceneTouchEvent.getY());
					handled = true;
				}

				this.mPointerID = TouchEvent.INVALID_POINTER_ID;
				return handled;
			} else {
				return false;
			}
		default:
			return false;
	}
}
 
Example 10
Source File: ScrollDetector.java    From tilt-game-android with MIT License 5 votes vote down vote up
private void triggerOnScrollFinished(final float pDistanceX, final float pDistanceY) {
	this.mTriggering = false;

	if (this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mScrollDetectorListener.onScrollFinished(this, this.mPointerID, pDistanceX, pDistanceY);
	}
}
 
Example 11
Source File: ContinuousHoldDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
void fireListener() {
	if(this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		final long holdTimeMilliseconds = System.currentTimeMillis() - this.mDownTimeMilliseconds;
		if(holdTimeMilliseconds >= this.mTriggerHoldMinimumMilliseconds) {
			if(this.mTriggering) {
				this.triggerOnHold(holdTimeMilliseconds);
			} else if(!this.mMaximumDistanceExceeded) {
				this.triggerOnHoldStarted();
			}
		}
	}
}
 
Example 12
Source File: HoldDetector.java    From tilt-game-android with MIT License 5 votes vote down vote up
protected void triggerOnHoldFinished(final long pHoldTimeMilliseconds) {
	this.mTriggering = false;

	if (this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mHoldDetectorListener.onHoldFinished(this, pHoldTimeMilliseconds, this.mPointerID, this.mHoldX, this.mHoldY);
	}
}
 
Example 13
Source File: HoldDetector.java    From tilt-game-android with MIT License 5 votes vote down vote up
/**
 * When {@link #isHolding()} this method will call through to {@link IHoldDetectorListener#onHoldFinished(HoldDetector, long, int, float, float).
 */
@Override
public void reset() {
	if (this.mTriggering) {
		this.triggerOnHoldFinished(System.currentTimeMillis() - this.mDownTimeMilliseconds);
	}

	this.mTriggering = false;
	this.mMaximumDistanceExceeded = false;
	this.mDownTimeMilliseconds = Long.MIN_VALUE;
	this.mPointerID = TouchEvent.INVALID_POINTER_ID;
}
 
Example 14
Source File: ClickDetector.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void reset() {
	this.mDownTimeMilliseconds = Long.MIN_VALUE;
	this.mPointerID = TouchEvent.INVALID_POINTER_ID;
}
 
Example 15
Source File: ScrollDetector.java    From tilt-game-android with MIT License 4 votes vote down vote up
private void triggerOnScrollStarted(final float pDistanceX, final float pDistanceY) {
	if (this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mScrollDetectorListener.onScrollStarted(this, this.mPointerID, pDistanceX, pDistanceY);
	}
}
 
Example 16
Source File: ClickDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void reset() {
	this.mDownTimeMilliseconds = Long.MIN_VALUE;
	this.mPointerID = TouchEvent.INVALID_POINTER_ID;
}
 
Example 17
Source File: HoldDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
protected void triggerOnHold(final long pHoldTimeMilliseconds) {
	if(this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mHoldDetectorListener.onHold(this, pHoldTimeMilliseconds, this.mPointerID, this.mHoldX, this.mHoldY);
	}
}
 
Example 18
Source File: HoldDetector.java    From tilt-game-android with MIT License 4 votes vote down vote up
protected void triggerOnHold(final long pHoldTimeMilliseconds) {
	if (this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mHoldDetectorListener.onHold(this, pHoldTimeMilliseconds, this.mPointerID, this.mHoldX, this.mHoldY);
	}
}
 
Example 19
Source File: ScrollDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
private void triggerOnScrollStarted(final float pDistanceX, final float pDistanceY) {
	if(this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mScrollDetectorListener.onScrollStarted(this, this.mPointerID, pDistanceX, pDistanceY);
	}
}
 
Example 20
Source File: ScrollDetector.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
private void triggerOnScroll(final float pDistanceX, final float pDistanceY) {
	if(this.mPointerID != TouchEvent.INVALID_POINTER_ID) {
		this.mScrollDetectorListener.onScroll(this, this.mPointerID, pDistanceX, pDistanceY);
	}
}