本文整理汇总了Java中com.badlogic.gdx.utils.Pool类的典型用法代码示例。如果您正苦于以下问题:Java Pool类的具体用法?Java Pool怎么用?Java Pool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pool类属于com.badlogic.gdx.utils包,在下文中一共展示了Pool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initEntities
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
private void initEntities(TextureAtlas textureAtlas) {
final float mobWidth = Polymorph.WORLD_WIDTH/4;
player = new Player(new Vector2(Polymorph.WORLD_WIDTH/2 - mobWidth/2, Polymorph.WORLD_HEIGHT/3-mobWidth),
new Dimension(mobWidth, mobWidth));
slots = new Array<Slot>();
slotPool = new Pool<Slot>() {
@Override
protected Slot newObject() {
return new Slot(new Vector2(SLOT_SPAWN_POINT),
new Vector2(slotVelocity),
new Dimension(mobWidth, mobWidth));
}
};
Dimension mapSize = new Dimension(Polymorph.WORLD_WIDTH, (int)(Polymorph.WORLD_HEIGHT*1.1f));
TextureRegion mapTexture = textureAtlas.findRegion("background");
Map mapFront = new Map(new Vector2(0, 0), mapVelocity, mapSize, mapTexture);
Map mapBack = new Map(new Vector2(0, -mapSize.height + 5), mapVelocity, mapSize, mapTexture);
maps = new Map[]{mapFront, mapBack};
}
示例2: Character
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
public Character() {
this.cooldownTimer = new float[5];
this.castTimer = new float[5];
this.casting = new boolean[5];
this.extraData = new Object[5];
this.cooldowns = new float[5];
this.costs = new float[5];
this.random = new Random();
finishedAttack = true;
vectorPool = new Pool<Vector2>() {
@Override
protected Vector2 newObject() {
return new Vector2();
}
@Override
protected void reset(Vector2 object) {
object.setZero();
}
};
}
示例3: QuadTree
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
/**
* create a quadtree collision manager with a default max_depth of 4 and a
* max_object count of 10.
*
* @param x
* @param y
* @param width
* @param height
*/
public QuadTree(float x, float y, float width, float height) {
check_object = new BasicGameObject();
check_object.init(null);
remove_objects = new IntArray();
culling = true;
follow_x =0;
follow_y =0;
bounds = new Rectangle(x - PAD, y - PAD, width + PAD * 2, height + PAD * 2);
objects = new Array<GameObject>();
follow_view = false;
final QuadTree m = this;
quad_pool = new Pool<QuadTree.Quad>() {
@Override
protected Quad newObject() {
return new Quad(m);
}
};
max_depth = 4;
max_objects = 10;
root = quad_pool.obtain();
root.init(null, 0, bounds.x, bounds.y, bounds.width, bounds.height);
ret_list = new Array<GameObject>();
}
示例4: Segment
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
/**
* Segment constructor
*/
public Segment(Position pos, SegmentDescriptor segmentType, float difficulty, final Pool<ProjectileEntity> horizontalProjectilePool, final Pool<ProjectileEntity> fallingProjectilePool, final AssetsHandler assetsHndlr, final BodyEditorDAL bodyDAL, final World box2DWorld) {
_assetsHndlr = assetsHndlr;
_segmentEntities = new ArrayList<Entity>();
_posX = pos.x;
_segmentDescriptor = segmentType;
_horizontalProjectilePool = horizontalProjectilePool;
_fallingProjectilePool = fallingProjectilePool;
_platformEntity = new PlatformEntity("Segment_PlatformEntity", pos, _SEGMENT_SCALE, segmentType.textureName, segmentType.bodyName, _assetsHndlr, bodyDAL, box2DWorld);
_segmentEntities.add(_platformEntity);
_activeProjectiles = new ArrayList<ProjectileEntity>();
_projectilesSources = new ArrayList<Position>();
if(!_segmentDescriptor.IsChangingHeight)
{
if( difficulty > 200)
difficulty = 200;
int sourceCount = 4 + (int)(Math.abs((Math.random()*_platformEntity.GetWidth()*_SEGMENT_SCALE - 5f)/4f)*(1f+difficulty/150f));
for(int pIdx = 0; pIdx < sourceCount ; pIdx += 3f*Math.random())
_projectilesSources.add(new Position(pos.x + 4*(int)pIdx, GameWorld.WORLD_VIEW_WIDTH));
}
}
示例5: BlockPools
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
public BlockPools(final Board board)
{
icePool = new Pool<IceBlock>()
{
@Override
protected IceBlock newObject()
{
return new IceBlock(iceTexture, board);
}
};
firePool = new Pool<FireBlock>()
{
protected FireBlock newObject()
{
return new FireBlock(fireTexture, board);
}
};
rangePool = new Pool<RangeBlock>()
{
protected RangeBlock newObject()
{
return new RangeBlock(rangeTexture, board);
}
};
}
示例6: Weapon
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
public Weapon(int animationId, int fireRate, int damage, int range, int bullSpeed, int knockback, boolean isMeele) {
this.fireRate = fireRate;
this.damage = damage;
this.range = range;
this.bullSpeed = bullSpeed;
this.animationId = animationId;
this.isMeele = isMeele;
this.lastShoot = 0;
this.isHitting = false;
this.state = 0;
this.knockBack = knockback;
bullets = new ArrayList<Bullet>();
bulletPool = new Pool<Bullet>() {
@Override
public Bullet newObject() {
return new Bullet();
}
};
}
示例7: act
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
public boolean act (float delta) {
if (complete) return true;
complete = true;
Pool pool = getPool();
setPool(null); // Ensure this action can't be returned to the pool while executing.
try {
Array<Action> actions = this.actions;
for (int i = 0, n = actions.size; i < n && actor != null; i++) {
if (!actions.get(i).act(delta)) complete = false;
if (actor == null) return true; // This action was removed.
}
return complete;
} finally {
setPool(pool);
}
}
示例8: act
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
public boolean act (float delta) {
if (complete) return true;
Pool pool = getPool();
setPool(null); // Ensure this action can't be returned to the pool while executing.
try {
if (!began) {
begin();
began = true;
}
time += delta;
complete = time >= duration;
float percent;
if (complete)
percent = 1;
else {
percent = time / duration;
if (interpolation != null) percent = interpolation.apply(percent);
}
update(reverse ? 1 - percent : percent);
if (complete) end();
return complete;
} finally {
setPool(pool);
}
}
示例9: getRenderables
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
@Override
public void getRenderables (Array<Renderable> renderables, Pool<Renderable> pool) {
renderedChunks = 0;
for (int i = 0; i < chunks.length; i++) {
VoxelChunk chunk = chunks[i];
Mesh mesh = meshes[i];
if (dirty[i]) {
int numVerts = chunk.calculateVertices(vertices);
numVertices[i] = numVerts / 4 * 6;
mesh.setVertices(vertices, 0, numVerts * VoxelChunk.VERTEX_SIZE);
dirty[i] = false;
}
if (numVertices[i] == 0) continue;
Renderable renderable = pool.obtain();
renderable.material = materials[i];
renderable.mesh = mesh;
renderable.meshPartOffset = 0;
renderable.meshPartSize = numVertices[i];
renderable.primitiveType = GL20.GL_TRIANGLES;
renderables.add(renderable);
renderedChunks++;
}
}
示例10: TaflBoard
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
public TaflBoard(int dimensions, int pieceTypes, ZorbistHash zorbistHash, RulesEngine rulesEngine, OrthographicCamera camera) {
super(dimensions, pieceTypes, zorbistHash);
this.rules = rulesEngine;
this.boardType = BoardType.getBoardType(dimensions);
this.movePool = new Pool<Move>() {
@Override
protected Move newObject() {
return new Move(this, boardSize);
}
};
this.camera = camera;
initialize();
}
示例11: getSimpleCopy
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
/**
* Gets a copy of this object but does not copy its parent or children
*
* @return The copied object
*/
@Override
public <T extends SceneGraphNode> T getSimpleCopy() {
Class<? extends AbstractOctreeWrapper> clazz = this.getClass();
Pool<? extends AbstractOctreeWrapper> pool = MyPools.get(clazz);
try {
AbstractOctreeWrapper instance = pool.obtain();
instance.copy = true;
instance.name = this.name;
instance.transform.set(this.transform);
instance.ct = this.ct;
if (this.localTransform != null)
instance.localTransform.set(this.localTransform);
return (T) instance;
} catch (Exception e) {
Logger.error(e);
}
return null;
}
示例12: freeAll
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
/** Frees the specified objects from the {@link #get(Class) pool}. Null objects within the array are silently ignored.
* @param samePool If true, objects don't need to be from the same pool but the pool must be looked up for each object. */
static public void freeAll(Array objects, boolean samePool) {
if (objects == null)
throw new IllegalArgumentException("Objects cannot be null.");
Pool pool = null;
for (int i = 0, n = objects.size; i < n; i++) {
Object object = objects.get(i);
if (object == null)
continue;
if (pool == null) {
pool = typePools.get(object.getClass().getName());
if (pool == null)
continue; // Ignore freeing an object that was never retained.
}
pool.free(object);
if (!samePool)
pool = null;
}
}
示例13: act
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
@Override
public boolean act (float delta) {
if (complete) return true;
complete = true;
Pool pool = getPool();
setPool(null); // Ensure this action can't be returned to the pool while executing.
try {
Array<Action3d> actions = this.actions;
for (int i = 0, n = actions.size; i < n && actor3d != null; i++) {
if (!actions.get(i).act(delta)) complete = false;
if (actor3d == null) return true; // This action was removed.
}
return complete;
} finally {
setPool(pool);
}
}
示例14: act
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
@Override
public boolean act (float delta) {
if (index >= actions.size) return true;
Pool<Action3d> pool = getPool();
setPool(null); // Ensure this action can't be returned to the pool while executings.
try {
if (actions.get(index).act(delta)) {
if (actor3d == null) return true; // This action was removed.
index++;
if (index >= actions.size) return true;
}
return false;
} finally {
setPool(pool);
}
}
示例15: act
import com.badlogic.gdx.utils.Pool; //导入依赖的package包/类
@Override
public boolean act (float delta) {
if (complete) return true;
Pool pool = getPool();
setPool(null); // Ensure this action can't be returned to the pool while executing.
try {
if (!began) {
begin();
began = true;
}
time += delta;
complete = time >= duration;
float percent;
if (complete)
percent = 1;
else {
percent = time / duration;
if (interpolation != null) percent = interpolation.apply(percent);
}
update(reverse ? 1 - percent : percent);
if (complete) end();
return complete;
} finally {
setPool(pool);
}
}