public void setFaceSize(final float pWidth, final float pHeight) { PositionerImmovableRelative positioner = PositionerImmovableRelative.getInstance(); for (IEntity entity : this.mEntities) { if (entity != null) { entity.setSize(pWidth, pHeight); positioner.center(entity.getParent(), entity); } } }
public static float getWrapScale( IEntity child, float pWidth, float pHeight, float boundingFactor) { if (child.getWidth() / pWidth > child.getHeight() / pHeight) { // Dealing in X return boundingFactor * pWidth / child.getWidth(); } else { // Dealing in Y return boundingFactor * pHeight / child.getHeight(); } }
public static void setChildrenVisible(IEntity e, boolean pVisible) { for (int i = 0; i < e.getChildCount(); i++) { IEntity child = e.getChildByIndex(i); if (child.getChildCount() > 0) { setChildrenVisible(child, pVisible); } child.setVisible(pVisible); } }
/** * Creates a button using provided entities as faces representing Button states * * @note Supplied entities will be moved to the center of Button * @param pNormal * @param pPressed * @param pDisabled */ public Button(final IEntity pNormal, final IEntity pPressed, final IEntity pDisabled) { setSize(pNormal.getWidth(), pNormal.getHeight()); if (pNormal == null) { throw new AndEngineRuntimeException("pNormal button face is null"); } this.mEntities[State.NORMAL.getEntityIndex()] = pNormal; this.mEntities[State.PRESSED.getEntityIndex()] = pPressed; this.mEntities[State.DISABLED.getEntityIndex()] = pDisabled; this.mState = State.NORMAL; positionEntities(); }
public static void printEntityDebugInfo(IEntity e, String name) { Log.d( "Riska", ((name != null) ? name : "Entity") + ": at (" + e.getX() + ", " + e.getY() + ") sized (" + e.getWidth() + ", " + e.getHeight() + ")"); }
public void positionEntities() { detachChild(mEntities[0]); detachChild(mEntities[1]); detachChild(mEntities[2]); attachChild(mEntities[0]); attachChild(mEntities[1]); attachChild(mEntities[2]); PositionerImmovableRelative positioner = PositionerImmovableRelative.getInstance(); for (IEntity entity : this.mEntities) { if (entity != null) { positioner.center(entity.getParent(), entity); } } detachChild(mEntities[0]); detachChild(mEntities[1]); detachChild(mEntities[2]); State savedState = mState; mState = State.UNDEFINED; changeState(savedState); }
protected void detachAndDisposeEntities(boolean onlyPreserved) { IEntity index; final int CHILD_COUNT = this.getChildCount(); final int HUD_CHILD_COUNT = SessionScene.HUD.getChildCount(); for (int i = 0; i < CHILD_COUNT; i++) { index = this.getChildByIndex(0); if (onlyPreserved ? index.getTag() != SessionScene.TAG_PRESERVE : true) { index.detachSelf(); if (!index.isDisposed()) index.dispose(); } } for (int i = 0; i < HUD_CHILD_COUNT; i++) { index = SessionScene.HUD.getChildByIndex(0); if (onlyPreserved ? index.getTag() != SessionScene.TAG_PRESERVE : true) { index.detachSelf(); if (!index.isDisposed()) index.dispose(); } } }
private void broadcast(final IEntity entity, final IEntityModifierListener listener) { entity.registerEntityModifier( new MoveModifier( 0.5f, BROADCAST_RIGHT, BROADCAST_LEVEL, BROADCAST_LEFT, BROADCAST_LEVEL, new IEntityModifierListener() { @Override public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) { entity.setVisible(true); listener.onModifierStarted(pModifier, pItem); } @Override public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) { entity.setVisible(false); listener.onModifierFinished(pModifier, pItem); } }, EaseBroadcast.getInstance())); }
public static void hideChildren(IEntity e) { for (int i = 0; i < e.getChildCount(); i++) { e.getChildByIndex(i).setVisible(false); } }
public static float halfY(IEntity e) { return 0.5f * e.getHeight(); }
public static float halfX(IEntity e) { return 0.5f * e.getWidth(); }
public static float topLocal(IEntity e) { return e.getHeight(); }
public static float rightLocal(IEntity e) { return e.getWidth(); }
public static float getCenterX(IEntity e) { return (0.5f * e.getWidth()); }
public static boolean contains(IEntity e, float pX, float pY) { return (isBetween(pX, 0, e.getWidth()) && isBetween(pY, 0, e.getHeight())); }
@Override protected void onSetInitialValue(final IEntity pEntity, final float pX) { pEntity.setX(pX); }
private float getItemSizeExtra(final IEntity pEntity) { return (mDirection != eDirection.DIR_HORIZONTAL) ? pEntity.getWidth() : pEntity.getHeight(); }
public static float posY(float perc, IEntity e) { return bottomGlobal(e) + perc * e.getHeight(); }
// ====================================================== // ====================================================== public static float posX(float perc, IEntity e) { return leftGlobal(e) + perc * e.getWidth(); }
public static void slideX(IEntity e, float distance) { e.setX(e.getX() + distance); }
public static float getCenterY(IEntity e) { return (0.5f * e.getHeight()); }
public static void showChildren(IEntity e) { for (int i = 0; i < e.getChildCount(); i++) { e.getChildByIndex(i).setVisible(true); } }
/** Works with scale */ public static float getScaledWidth(IEntity e) { return (Math.abs(e.getScaleX() * e.getWidth())); }
public static float bottomGlobal(IEntity e) { return e.getY() - 0.5f * e.getHeight(); }
public static float leftGlobal(IEntity e) { return e.getX() - 0.5f * e.getWidth(); }
/** Works with scale */ public static float getScaledHeight(IEntity e) { return (Math.abs(e.getScaleY() * e.getHeight())); }
@Override protected void onChangeValues( final float pSecondsElapsed, final IEntity pEntity, final float pX, final float pY) { pEntity.setPosition(pEntity.getX() + pX, pEntity.getY() + pY); }
public static float rightGlobal(IEntity e) { return e.getX() + 0.5f * e.getWidth(); }
@Override protected void onSetValue(final IEntity pEntity, final float pPercentageDone, final float pX) { pEntity.setX(pX); }
public static float topGlobal(IEntity e) { return e.getY() + 0.5f * e.getHeight(); }