Ejemplo n.º 1
0
  /**
   * To retrieve the current image index that is currently animating and then updating the current
   * to the next image
   *
   * @param id
   */
  public void changeCurrIndex(Integer id) {
    // gives the animation name give the entity id
    String animation = mCurrentAnimation.get(id);
    // gets  the actual array assoc with the name
    CircularArray<Texture2> arr = mReelsNameAssoc.get(animation);

    // checks if the key is in the hash table
    if (mUpdateCurrAni.containsKey(id)) {
      int imgIndex = mUpdateCurrAni.get(id); // Retrieve the last draw's image index

      mUpdateCurrAni.remove(id); // remove it

      if (imgIndex < arr.size() - 1) { // check if the current index is still within bound

        imgIndex++; // increment the index

        mUpdateCurrAni.put(id, imgIndex); //  put next index in
      } else {

        imgIndex = 0; // when we are at the last index wrap back to the beginning
      }

    } else {
      // else is it not in the table we add with the index being 0
      mUpdateCurrAni.put(id, 0);
    }
  }
Ejemplo n.º 2
0
  /**
   * Method that will get one frame of image from the animation for the given entity and image index
   *
   * @param s
   * @param frameID
   * @return the image
   */
  public Texture2 getImage(String entityAniName, int frameID) {

    CircularArray<Texture2> frame = mReelsNameAssoc.get(entityAniName); // return the reels

    Texture2 i = frame.get(frameID); // return the frame

    return i;
  }