Example #1
0
  public SpriteAnimator(
      Texture tex,
      int numTextures,
      int numInRow,
      String caller,
      int framesPerSecond,
      GameObject parent) {
    atlas = new TextureAtlas();

    int width = (int) (tex.getWidth() / (float) numInRow);
    int rows = (int) Math.ceil(numTextures / (float) numInRow);
    int height = (int) (tex.getHeight() / (float) rows);

    int x, y;

    for (int r = 0; r < rows; ++r) {
      y = r * height;
      for (int c = 0; c < numInRow; ++c) {
        x = c * width;
        atlas.addRegion(caller + (c + (r * numInRow) + 1), tex, x, y, width, height);
      }
    }
    init(atlas, caller, framesPerSecond, parent);
  }