org.andengine.entity.scene.ITouchArea Java Examples
The following examples show how to use
org.andengine.entity.scene.ITouchArea.
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: MenuScene.java From tilt-game-android with MIT License | 5 votes |
@Override public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final ITouchArea pTouchArea, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { final IMenuItem menuItem = ((IMenuItem)pTouchArea); switch (pSceneTouchEvent.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: if ((this.mSelectedMenuItem != null) && (this.mSelectedMenuItem != menuItem)) { this.mSelectedMenuItem.onUnselected(); } this.mSelectedMenuItem = menuItem; this.mSelectedMenuItem.onSelected(); break; case MotionEvent.ACTION_UP: if (this.mOnMenuItemClickListener != null) { final boolean handled = this.mOnMenuItemClickListener.onMenuItemClicked(this, menuItem, pTouchAreaLocalX, pTouchAreaLocalY); menuItem.onUnselected(); this.mSelectedMenuItem = null; return handled; } break; case MotionEvent.ACTION_CANCEL: menuItem.onUnselected(); this.mSelectedMenuItem = null; break; } return true; }
Example #2
Source File: MenuScene.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final ITouchArea pTouchArea, final float pTouchAreaLocalX, final float pTouchAreaLocalY) { final IMenuItem menuItem = ((IMenuItem)pTouchArea); switch(pSceneTouchEvent.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: if(this.mSelectedMenuItem != null && this.mSelectedMenuItem != menuItem) { this.mSelectedMenuItem.onUnselected(); } this.mSelectedMenuItem = menuItem; this.mSelectedMenuItem.onSelected(); break; case MotionEvent.ACTION_UP: if(this.mOnMenuItemClickListener != null) { final boolean handled = this.mOnMenuItemClickListener.onMenuItemClicked(this, menuItem, pTouchAreaLocalX, pTouchAreaLocalY); menuItem.onUnselected(); this.mSelectedMenuItem = null; return handled; } break; case MotionEvent.ACTION_CANCEL: menuItem.onUnselected(); this.mSelectedMenuItem = null; break; } return true; }