Example usage for com.badlogic.gdx.utils Pool Pool

List of usage examples for com.badlogic.gdx.utils Pool Pool

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils Pool Pool.

Prototype

public Pool(int initialCapacity, int max) 

Source Link

Usage

From source file:com.badlydrawngames.veryangryrobots.World.java

License:Apache License

/** Constructs a new {@link World}. */
public World(DifficultyManager difficultyManager) {
    this.difficultyManager = difficultyManager;
    notifier = new WorldNotifier();
    minX = 0;/*from ww w.j a  v  a 2 s  .co  m*/
    maxX = WALL_WIDTH * HCELLS;
    minY = 0;
    maxY = WALL_WIDTH * VCELLS;
    roomBounds = new Rectangle(minX, minY, maxX - minX, maxY - minY);
    player = new Player();
    captain = new Captain();
    playerPos = new Vector2();
    roomBuilder = new RoomBuilder(HCELLS, VCELLS);
    roomGrid = new Grid(HCELLS * 2, VCELLS * 2, maxX, maxY);

    shotPool = new Pool<PlayerShot>(MAX_PLAYER_SHOTS, MAX_PLAYER_SHOTS) {
        @Override
        protected PlayerShot newObject() {
            return new PlayerShot();
        }
    };

    robotPool = new Pool<Robot>(MAX_ROBOTS, MAX_ROBOTS) {
        @Override
        protected Robot newObject() {
            return new Robot();
        }
    };

    robotShotPool = new Pool<RobotShot>(MAX_ROBOT_SHOTS, MAX_ROBOT_SHOTS) {
        @Override
        protected RobotShot newObject() {
            return new RobotShot();
        }
    };
}

From source file:com.esotericsoftware.spine.utils.SkeletonActorPool.java

License:Open Source License

public SkeletonActorPool(SkeletonRenderer renderer, SkeletonData skeletonData, AnimationStateData stateData,
        int initialCapacity, int max) {
    super(initialCapacity, max);

    this.renderer = renderer;
    this.skeletonData = skeletonData;
    this.stateData = stateData;

    obtained = new Array(false, initialCapacity);

    skeletonPool = new Pool<Skeleton>(initialCapacity, max) {
        protected Skeleton newObject() {
            return new Skeleton(SkeletonActorPool.this.skeletonData);
        }// w ww .  j  a  v  a2  s .  c o m

        protected void reset(Skeleton skeleton) {
            skeleton.setColor(Color.WHITE);
            skeleton.setFlip(false, false);
            skeleton.setSkin((Skin) null);
            skeleton.setSkin(SkeletonActorPool.this.skeletonData.getDefaultSkin());
            skeleton.setToSetupPose();
        }
    };

    statePool = new Pool<AnimationState>(initialCapacity, max) {
        protected AnimationState newObject() {
            return new AnimationState(SkeletonActorPool.this.stateData);
        }

        protected void reset(AnimationState state) {
            state.clearTracks();
            state.clearListeners();
        }
    };
}

From source file:com.ridiculousRPG.util.BitmapFontCachePool.java

License:Apache License

/**
 * Returns an object from this pool. The object may be new or reused
 * (previously {@link #free(Object) freed}).<br>
 * You have to dispose the fonts by yourself.
 * /*from  w w  w .ja v  a2  s . com*/
 * @param font
 * @return
 */
public BitmapFontCache obtain(final BitmapFont font) {
    Pool<BitmapFontCache> fontCache = pool.get(font);
    if (fontCache == null) {
        fontCache = new Pool<BitmapFontCache>(64, 256) {

            @Override
            protected BitmapFontCache newObject() {
                return new BitmapFontCache(font);
            }
        };
        pool.put(font, fontCache);
    }
    return fontCache.obtain();
}

From source file:com.todoroo.zxzx.World.java

License:Apache License

/** Constructs a new {@link World}. */
public World() {//  w w  w  .j ava2s  .c  om
    notifier = new WorldNotifier();
    roomBounds = new Rectangle(0, 0, 800, 1280);
    player = new Player();
    level = 0;
    gameTime = 0;

    shotPool = new Pool<PlayerShot>(MAX_PLAYER_SHOTS, MAX_PLAYER_SHOTS) {
        @Override
        protected PlayerShot newObject() {
            return new PlayerShot();
        }
    };

    levelManager = new LevelManager();
}