Example #1
0
 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();
   }
 }
Example #2
0
 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()
           + ")");
 }
Example #3
0
  /**
   * 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();
  }
Example #4
0
 public static float topLocal(IEntity e) {
   return e.getHeight();
 }
Example #5
0
 public static float bottomGlobal(IEntity e) {
   return e.getY() - 0.5f * e.getHeight();
 }
Example #6
0
 public static float topGlobal(IEntity e) {
   return e.getY() + 0.5f * e.getHeight();
 }
Example #7
0
 public static float posY(float perc, IEntity e) {
   return bottomGlobal(e) + perc * e.getHeight();
 }
Example #8
0
 public static float getCenterY(IEntity e) {
   return (0.5f * e.getHeight());
 }
Example #9
0
 public static void wrap(Text text, IEntity parent, float boundingFactor) {
   wrap(text, parent.getWidth(), parent.getHeight(), boundingFactor);
 }
Example #10
0
 public static boolean notFilling(IEntity child, IEntity parent, float factor) {
   return (child.getWidth() < (factor * parent.getWidth())
       || child.getHeight() < (factor * parent.getHeight()));
 }
Example #11
0
 public static boolean outOfBounds(IEntity child, IEntity parent, float factor) {
   return (child.getWidth() > (factor * parent.getWidth())
       || child.getHeight() > (factor * parent.getHeight()));
 }
Example #12
0
 public static float getWrapScale(IEntity child, IEntity parent, float boundingFactor) {
   return getWrapScale(child, parent.getWidth(), parent.getHeight(), boundingFactor);
 }
Example #13
0
  public static void wrapY(Text text, IEntity parent, float textBoundingFactorY) {
    float pScale =
        getWrapScale(text, parent.getWidth(), textBoundingFactorY * parent.getHeight(), 1f);

    text.setScale(pScale);
  }
Example #14
0
  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);
  }
Example #15
0
 public static void wrap(IEntity child, IEntity parent, float boundingFactor) {
   wrap(child, parent.getWidth(), parent.getHeight(), boundingFactor);
 }
Example #16
0
 public static float halfY(IEntity e) {
   return 0.5f * e.getHeight();
 }
Example #17
0
 public static boolean contains(IEntity e, float pX, float pY) {
   return (isBetween(pX, 0, e.getWidth()) && isBetween(pY, 0, e.getHeight()));
 }
Example #18
0
 public static float getLowerBoundsY(IEntity e) {
   return getLowerBoundsY(e.getY(), e.getHeight());
 }
Example #19
0
 private float getItemSizeExtra(final IEntity pEntity) {
   return (mDirection != eDirection.DIR_HORIZONTAL) ? pEntity.getWidth() : pEntity.getHeight();
 }
Example #20
0
 /** Works with scale */
 public static float getScaledHeight(IEntity e) {
   return (Math.abs(e.getScaleY() * e.getHeight()));
 }