Example #1
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 #2
0
 // ===========================================================
 // Methods for/from SuperClass/Interfaces
 // ===========================================================
 protected void attachDefaultFace() {
   // we assume that NORMAL face HAS to be provided
   attachChild(this.mEntities[State.NORMAL.getEntityIndex()]);
 }