當前位置: 首頁>>代碼示例>>Java>>正文


Java Pool類代碼示例

本文整理匯總了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};
}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:22,代碼來源:PolyGame.java

示例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();
        }
    };
}
 
開發者ID:EtherWorks,項目名稱:arcadelegends-gg,代碼行數:24,代碼來源:Character.java

示例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>();
}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:33,代碼來源:QuadTree.java

示例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));
	}
}
 
開發者ID:mitsuhirato,項目名稱:TheEndlessCastle,代碼行數:27,代碼來源:Segment.java

示例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);
        }
    };
}
 
開發者ID:mfkaptan,項目名稱:freeze-fire-tag,代碼行數:27,代碼來源:BlockPools.java

示例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();
		}
	};
}
 
開發者ID:ochi12,項目名稱:TopDown,代碼行數:21,代碼來源:Weapon.java

示例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);
	}
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:17,代碼來源:ParallelAction.java

示例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);
	}
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:26,代碼來源:TemporalAction.java

示例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++;
	}
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:24,代碼來源:VoxelWorld.java

示例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();
}
 
開發者ID:apotapov,項目名稱:tafl,代碼行數:17,代碼來源:TaflBoard.java

示例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;
}
 
開發者ID:langurmonkey,項目名稱:gaiasky,代碼行數:25,代碼來源:AbstractOctreeWrapper.java

示例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;
    }
}
 
開發者ID:langurmonkey,項目名稱:gaiasky,代碼行數:21,代碼來源:MyPools.java

示例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);
        }
}
 
開發者ID:pyros2097,項目名稱:Scene3d,代碼行數:18,代碼來源:ParallelAction.java

示例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);
        }
}
 
開發者ID:pyros2097,項目名稱:Scene3d,代碼行數:17,代碼來源:SequenceAction.java

示例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);
        }
}
 
開發者ID:pyros2097,項目名稱:Scene3d,代碼行數:27,代碼來源:TemporalAction.java


注:本文中的com.badlogic.gdx.utils.Pool類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。