Exemple #1
0
 public void setFaceSize(final float pWidth, final float pHeight) {
   PositionerImmovableRelative positioner = PositionerImmovableRelative.getInstance();
   for (IEntity entity : this.mEntities) {
     if (entity != null) {
       entity.setSize(pWidth, pHeight);
       positioner.center(entity.getParent(), entity);
     }
   }
 }
Exemple #2
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();
   }
 }
Exemple #3
0
  public static void setChildrenVisible(IEntity e, boolean pVisible) {
    for (int i = 0; i < e.getChildCount(); i++) {
      IEntity child = e.getChildByIndex(i);

      if (child.getChildCount() > 0) {
        setChildrenVisible(child, pVisible);
      }

      child.setVisible(pVisible);
    }
  }
Exemple #4
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();
  }
Exemple #5
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()
           + ")");
 }
Exemple #6
0
  public void positionEntities() {
    detachChild(mEntities[0]);
    detachChild(mEntities[1]);
    detachChild(mEntities[2]);

    attachChild(mEntities[0]);
    attachChild(mEntities[1]);
    attachChild(mEntities[2]);

    PositionerImmovableRelative positioner = PositionerImmovableRelative.getInstance();
    for (IEntity entity : this.mEntities) {
      if (entity != null) {
        positioner.center(entity.getParent(), entity);
      }
    }

    detachChild(mEntities[0]);
    detachChild(mEntities[1]);
    detachChild(mEntities[2]);

    State savedState = mState;
    mState = State.UNDEFINED;
    changeState(savedState);
  }
  protected void detachAndDisposeEntities(boolean onlyPreserved) {
    IEntity index;

    final int CHILD_COUNT = this.getChildCount();
    final int HUD_CHILD_COUNT = SessionScene.HUD.getChildCount();

    for (int i = 0; i < CHILD_COUNT; i++) {
      index = this.getChildByIndex(0);
      if (onlyPreserved ? index.getTag() != SessionScene.TAG_PRESERVE : true) {
        index.detachSelf();
        if (!index.isDisposed()) index.dispose();
      }
    }

    for (int i = 0; i < HUD_CHILD_COUNT; i++) {
      index = SessionScene.HUD.getChildByIndex(0);
      if (onlyPreserved ? index.getTag() != SessionScene.TAG_PRESERVE : true) {
        index.detachSelf();
        if (!index.isDisposed()) index.dispose();
      }
    }
  }
  private void broadcast(final IEntity entity, final IEntityModifierListener listener) {
    entity.registerEntityModifier(
        new MoveModifier(
            0.5f,
            BROADCAST_RIGHT,
            BROADCAST_LEVEL,
            BROADCAST_LEFT,
            BROADCAST_LEVEL,
            new IEntityModifierListener() {
              @Override
              public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) {
                entity.setVisible(true);
                listener.onModifierStarted(pModifier, pItem);
              }

              @Override
              public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
                entity.setVisible(false);
                listener.onModifierFinished(pModifier, pItem);
              }
            },
            EaseBroadcast.getInstance()));
  }
Exemple #9
0
 public static void hideChildren(IEntity e) {
   for (int i = 0; i < e.getChildCount(); i++) {
     e.getChildByIndex(i).setVisible(false);
   }
 }
Exemple #10
0
 public static float halfY(IEntity e) {
   return 0.5f * e.getHeight();
 }
Exemple #11
0
 public static float halfX(IEntity e) {
   return 0.5f * e.getWidth();
 }
Exemple #12
0
 public static float topLocal(IEntity e) {
   return e.getHeight();
 }
Exemple #13
0
 public static float rightLocal(IEntity e) {
   return e.getWidth();
 }
Exemple #14
0
 public static float getCenterX(IEntity e) {
   return (0.5f * e.getWidth());
 }
Exemple #15
0
 public static boolean contains(IEntity e, float pX, float pY) {
   return (isBetween(pX, 0, e.getWidth()) && isBetween(pY, 0, e.getHeight()));
 }
 @Override
 protected void onSetInitialValue(final IEntity pEntity, final float pX) {
   pEntity.setX(pX);
 }
Exemple #17
0
 private float getItemSizeExtra(final IEntity pEntity) {
   return (mDirection != eDirection.DIR_HORIZONTAL) ? pEntity.getWidth() : pEntity.getHeight();
 }
Exemple #18
0
 public static float posY(float perc, IEntity e) {
   return bottomGlobal(e) + perc * e.getHeight();
 }
Exemple #19
0
 // ======================================================
 // ======================================================
 public static float posX(float perc, IEntity e) {
   return leftGlobal(e) + perc * e.getWidth();
 }
Exemple #20
0
 public static void slideX(IEntity e, float distance) {
   e.setX(e.getX() + distance);
 }
Exemple #21
0
 public static float getCenterY(IEntity e) {
   return (0.5f * e.getHeight());
 }
Exemple #22
0
 public static void showChildren(IEntity e) {
   for (int i = 0; i < e.getChildCount(); i++) {
     e.getChildByIndex(i).setVisible(true);
   }
 }
Exemple #23
0
 /** Works with scale */
 public static float getScaledWidth(IEntity e) {
   return (Math.abs(e.getScaleX() * e.getWidth()));
 }
Exemple #24
0
 public static float bottomGlobal(IEntity e) {
   return e.getY() - 0.5f * e.getHeight();
 }
Exemple #25
0
 public static float leftGlobal(IEntity e) {
   return e.getX() - 0.5f * e.getWidth();
 }
Exemple #26
0
 /** Works with scale */
 public static float getScaledHeight(IEntity e) {
   return (Math.abs(e.getScaleY() * e.getHeight()));
 }
 @Override
 protected void onChangeValues(
     final float pSecondsElapsed, final IEntity pEntity, final float pX, final float pY) {
   pEntity.setPosition(pEntity.getX() + pX, pEntity.getY() + pY);
 }
Exemple #28
0
 public static float rightGlobal(IEntity e) {
   return e.getX() + 0.5f * e.getWidth();
 }
 @Override
 protected void onSetValue(final IEntity pEntity, final float pPercentageDone, final float pX) {
   pEntity.setX(pX);
 }
Exemple #30
0
 public static float topGlobal(IEntity e) {
   return e.getY() + 0.5f * e.getHeight();
 }