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 printEntityDebugInfo(IEntity e, String name) { Log.d( "Riska", ((name != null) ? name : "Entity") + ": at (" + e.getX() + ", " + e.getY() + ") sized (" + e.getWidth() + ", " + e.getHeight() + ")"); }
/** * 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 float topLocal(IEntity e) { return e.getHeight(); }
public static float bottomGlobal(IEntity e) { return e.getY() - 0.5f * e.getHeight(); }
public static float topGlobal(IEntity e) { return e.getY() + 0.5f * e.getHeight(); }
public static float posY(float perc, IEntity e) { return bottomGlobal(e) + perc * e.getHeight(); }
public static float getCenterY(IEntity e) { return (0.5f * e.getHeight()); }
public static void wrap(Text text, IEntity parent, float boundingFactor) { wrap(text, parent.getWidth(), parent.getHeight(), boundingFactor); }
public static boolean notFilling(IEntity child, IEntity parent, float factor) { return (child.getWidth() < (factor * parent.getWidth()) || child.getHeight() < (factor * parent.getHeight())); }
public static boolean outOfBounds(IEntity child, IEntity parent, float factor) { return (child.getWidth() > (factor * parent.getWidth()) || child.getHeight() > (factor * parent.getHeight())); }
public static float getWrapScale(IEntity child, IEntity parent, float boundingFactor) { return getWrapScale(child, parent.getWidth(), parent.getHeight(), boundingFactor); }
public static void wrapY(Text text, IEntity parent, float textBoundingFactorY) { float pScale = getWrapScale(text, parent.getWidth(), textBoundingFactorY * parent.getHeight(), 1f); text.setScale(pScale); }
public static void wrap(IEntity child, float pWidth, float pHeight, float boundingFactor) { float scale = getWrapScale(child, pWidth, pHeight, boundingFactor); // child.setScale(scale); child.setSize(child.getWidth() * scale, child.getHeight() * scale); }
public static void wrap(IEntity child, IEntity parent, float boundingFactor) { wrap(child, parent.getWidth(), parent.getHeight(), boundingFactor); }
public static float halfY(IEntity e) { return 0.5f * e.getHeight(); }
public static boolean contains(IEntity e, float pX, float pY) { return (isBetween(pX, 0, e.getWidth()) && isBetween(pY, 0, e.getHeight())); }
public static float getLowerBoundsY(IEntity e) { return getLowerBoundsY(e.getY(), e.getHeight()); }
private float getItemSizeExtra(final IEntity pEntity) { return (mDirection != eDirection.DIR_HORIZONTAL) ? pEntity.getWidth() : pEntity.getHeight(); }
/** Works with scale */ public static float getScaledHeight(IEntity e) { return (Math.abs(e.getScaleY() * e.getHeight())); }