本文整理汇总了Java中org.andengine.entity.scene.menu.item.IMenuItem类的典型用法代码示例。如果您正苦于以下问题:Java IMenuItem类的具体用法?Java IMenuItem怎么用?Java IMenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMenuItem类属于org.andengine.entity.scene.menu.item包,在下文中一共展示了IMenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMenuItemX
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
protected float getMenuItemX(final MenuScene pMenuScene, final int pIndex) {
final float menuSceneWidth = pMenuScene.getWidth();
final IMenuItem menuItem = pMenuScene.getMenuItem(pIndex);
final float menuItemWidth = menuItem.getWidth();
/* Determine horizontal position. */
final float x;
switch (this.mHorizontalAlign) {
case LEFT:
x = menuItemWidth * 0.5f;
break;
case CENTER:
x = menuSceneWidth * 0.5f;
break;
case RIGHT:
x = menuSceneWidth - (menuItemWidth * 0.5f);
break;
default:
throw new IllegalArgumentException("Unexpected " + HorizontalAlign.class.getSimpleName() + " with value: '" + this.mHorizontalAlign + "'.");
}
return x + this.mOffsetX;
}
示例2: getFromX
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
protected float getFromX(final MenuScene pMenuScene, final IMenuItem pMenuItem, final float pX) {
switch (this.mDirection) {
case UP:
case DOWN:
return pX;
case DOWN_LEFT:
case UP_LEFT:
case LEFT:
return pMenuScene.getWidth() + (pMenuItem.getWidth() * 0.5f);
case DOWN_RIGHT:
case UP_RIGHT:
case RIGHT:
return -(pMenuItem.getWidth() * 0.5f);
default:
throw new IllegalArgumentException();
}
}
示例3: getFromY
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
protected float getFromY(final MenuScene pMenuScene, final IMenuItem pMenuItem, final float pY) {
switch (this.mDirection) {
case DOWN_LEFT:
case DOWN:
case DOWN_RIGHT:
return pMenuScene.getHeight() + (pMenuItem.getHeight() * 0.5f);
case LEFT:
case RIGHT:
return pY;
case UP_LEFT:
case UP:
case UP_RIGHT:
return -(pMenuItem.getHeight() * 0.5f);
default:
throw new IllegalArgumentException();
}
}
示例4: onMenuItemClicked
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
@Override
public boolean onMenuItemClicked(MenuScene pMenuScene, IMenuItem pMenuItem, float pMenuItemLocalX, float pMenuItemLocalY) {
int id = pMenuItem.getID();
Logger.log(TAG, "Menu item clicked");
for (int menuId : mLevels) {
if (id == menuId) {
Logger.log(TAG, "Selected level " + menuId);
AbstractGameActivity activity = getActivity();
if (activity != null) {
Logger.log(TAG, "Creating game scene");
SceneManager sceneManager = activity.getSceneManager();
sceneManager.uploadScene(SceneType.GAME_SCENE);
GameScene gameScene = (GameScene) sceneManager.getScene(SceneType.GAME_SCENE);
gameScene.setLevel(menuId);
gameScene.populateScene();
activity.getEngine().setScene(gameScene);
return true;
}
return false;
}
}
return false;
}
示例5: prepareAnimations
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
@Override
public void prepareAnimations(final ArrayList<IMenuItem> pMenuItems, final float pCameraWidth, final float pCameraHeight) {
final float maximumWidth = this.getMaximumWidth(pMenuItems);
final float overallHeight = this.getOverallHeight(pMenuItems);
final float baseY = (pCameraHeight - overallHeight) * 0.5f;
final float menuItemSpacing = this.mMenuItemSpacing;
float offsetY = 0;
final int menuItemCount = pMenuItems.size();
for(int i = 0; i < menuItemCount; i++) {
final IMenuItem menuItem = pMenuItems.get(i);
menuItem.setPosition(-maximumWidth, baseY + offsetY);
offsetY += menuItem.getHeight() + menuItemSpacing;
}
}
示例6: resetMenuSceneAnimations
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
@Override
public void resetMenuSceneAnimations(final MenuScene pMenuScene) {
final int menuItemCount = pMenuScene.getMenuItemCount();
for (int i = 0; i < menuItemCount; i++) {
final IMenuItem menuItem = pMenuScene.getMenuItem(i);
final float x = this.getMenuItemX(pMenuScene, i);
final float y = this.getMenuItemY(pMenuScene, i);
this.onMenuItemPositionReset(pMenuScene, i, menuItem, x, y);
}
}
示例7: clearMenuItems
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
public void clearMenuItems() {
for (int i = this.mMenuItems.size() - 1; i >= 0; i--) {
final IMenuItem menuItem = this.mMenuItems.remove(i);
this.detachChild(menuItem);
this.unregisterTouchArea(menuItem);
}
}
示例8: onAreaTouched
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
@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;
}
示例9: ScaleMenuItemDecorator
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
public ScaleMenuItemDecorator(final IMenuItem pMenuItem, final float pSelectedScale, final float pUnselectedScale) {
super(pMenuItem);
this.mSelectedScale = pSelectedScale;
this.mUnselectedScale = pUnselectedScale;
pMenuItem.setScale(pUnselectedScale);
}
示例10: getMenuItemY
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
protected float getMenuItemY(final MenuScene pMenuScene, final int pIndex) {
final float menuSceneHeight = pMenuScene.getHeight();
final IMenuItem menuItem = pMenuScene.getMenuItem(pIndex);
/* Prepare vertical position. */
float baseY;
switch (this.mVerticalAlign) {
case TOP:
baseY = menuSceneHeight;
break;
case CENTER:
baseY = (0.5f * menuSceneHeight) + (this.mOverallHeight * 0.5f);
break;
case BOTTOM:
baseY = this.mOverallHeight;
break;
default:
throw new IllegalArgumentException("Unexpected " + VerticalAlign.class.getSimpleName() + " with value: '" + this.mVerticalAlign + "'.");
}
final float menuItemHeight = menuItem.getHeight();
/* Determine vertical position. */
final float y = baseY - (menuItemHeight * 0.5f) - (pIndex * (menuItemHeight + this.mMenuItemSpacing));
return y + this.mOffsetY;
}
示例11: ColorMenuItemDecorator
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
public ColorMenuItemDecorator(final IMenuItem pMenuItem, final Color pSelectedColor, final Color pUnselectedColor) {
super(pMenuItem);
this.mSelectedColor = pSelectedColor;
this.mUnselectedColor = pUnselectedColor;
pMenuItem.setColor(pUnselectedColor);
}
示例12: onMenuItemPositionBuilt
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
@Override
protected void onMenuItemPositionBuilt(final MenuScene pMenuScene, final int pIndex, final IMenuItem pMenuItem, final float pX, final float pY) {
final float fromX = getFromX(pMenuScene, pMenuItem, pX);
final float fromY = getFromY(pMenuScene, pMenuItem, pY);
pMenuItem.setPosition(fromX, fromY);
final MoveModifier moveModifier = new MoveModifier(SlideMenuSceneAnimator.DURATION, fromX, fromY, pX, pY, this.mEaseFunction);
moveModifier.setAutoUnregisterWhenFinished(false);
pMenuItem.registerEntityModifier(moveModifier);
}
示例13: onMenuItemPositionReset
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
@Override
protected void onMenuItemPositionReset(final MenuScene pMenuScene, final int pIndex, final IMenuItem pMenuItem, final float pX, final float pY) {
final float fromX = getFromX(pMenuScene, pMenuItem, pX);
final float fromY = getFromY(pMenuScene, pMenuItem, pY);
pMenuItem.setPosition(fromX, fromY);
pMenuItem.resetEntityModifiers();
}
示例14: onMenuItemPositionBuilt
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
@Override
protected void onMenuItemPositionBuilt(final MenuScene pMenuScene, final int pIndex, final IMenuItem pMenuItem, final float pX, final float pY) {
pMenuItem.setPosition(pX, pY);
final AlphaModifier alphaModifier = new AlphaModifier(AlphaMenuSceneAnimator.DURATION, AlphaMenuSceneAnimator.ALPHA_FROM, AlphaMenuSceneAnimator.ALPHA_TO, this.mEaseFunction);
alphaModifier.setAutoUnregisterWhenFinished(false);
pMenuItem.registerEntityModifier(alphaModifier);
}
示例15: onMenuItemPositionReset
import org.andengine.entity.scene.menu.item.IMenuItem; //导入依赖的package包/类
@Override
protected void onMenuItemPositionReset(final MenuScene pMenuScene, final int pIndex, final IMenuItem pMenuItem, final float pX, final float pY) {
pMenuItem.setPosition(pX, pY);
pMenuItem.resetEntityModifiers();
pMenuItem.setAlpha(AlphaMenuSceneAnimator.ALPHA_FROM);
}