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