Ejemplo n.º 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();
   }
 }
Ejemplo n.º 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()
           + ")");
 }
Ejemplo n.º 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();
  }
Ejemplo n.º 4
0
 public static float topLocal(IEntity e) {
   return e.getHeight();
 }
Ejemplo n.º 5
0
 public static float bottomGlobal(IEntity e) {
   return e.getY() - 0.5f * e.getHeight();
 }
Ejemplo n.º 6
0
 public static float topGlobal(IEntity e) {
   return e.getY() + 0.5f * e.getHeight();
 }
Ejemplo n.º 7
0
 public static float posY(float perc, IEntity e) {
   return bottomGlobal(e) + perc * e.getHeight();
 }
Ejemplo n.º 8
0
 public static float getCenterY(IEntity e) {
   return (0.5f * e.getHeight());
 }
Ejemplo n.º 9
0
 public static void wrap(Text text, IEntity parent, float boundingFactor) {
   wrap(text, parent.getWidth(), parent.getHeight(), boundingFactor);
 }
Ejemplo n.º 10
0
 public static boolean notFilling(IEntity child, IEntity parent, float factor) {
   return (child.getWidth() < (factor * parent.getWidth())
       || child.getHeight() < (factor * parent.getHeight()));
 }
Ejemplo n.º 11
0
 public static boolean outOfBounds(IEntity child, IEntity parent, float factor) {
   return (child.getWidth() > (factor * parent.getWidth())
       || child.getHeight() > (factor * parent.getHeight()));
 }
Ejemplo n.º 12
0
 public static float getWrapScale(IEntity child, IEntity parent, float boundingFactor) {
   return getWrapScale(child, parent.getWidth(), parent.getHeight(), boundingFactor);
 }
Ejemplo n.º 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);
  }
Ejemplo n.º 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);
  }
Ejemplo n.º 15
0
 public static void wrap(IEntity child, IEntity parent, float boundingFactor) {
   wrap(child, parent.getWidth(), parent.getHeight(), boundingFactor);
 }
Ejemplo n.º 16
0
 public static float halfY(IEntity e) {
   return 0.5f * e.getHeight();
 }
Ejemplo n.º 17
0
 public static boolean contains(IEntity e, float pX, float pY) {
   return (isBetween(pX, 0, e.getWidth()) && isBetween(pY, 0, e.getHeight()));
 }
Ejemplo n.º 18
0
 public static float getLowerBoundsY(IEntity e) {
   return getLowerBoundsY(e.getY(), e.getHeight());
 }
Ejemplo n.º 19
0
 private float getItemSizeExtra(final IEntity pEntity) {
   return (mDirection != eDirection.DIR_HORIZONTAL) ? pEntity.getWidth() : pEntity.getHeight();
 }
Ejemplo n.º 20
0
 /** Works with scale */
 public static float getScaledHeight(IEntity e) {
   return (Math.abs(e.getScaleY() * e.getHeight()));
 }