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