Java Code Examples for com.badlogic.gdx.utils.Array#clear()

The following examples show how to use com.badlogic.gdx.utils.Array#clear() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValueArrayMap.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
/** Warning: returned array will be reused! */
public Array<K> getKeys() {
    Array<K> result = tmpKeyArray;
    result.clear();

    for (K key : map.keySet()) {
        result.add(key);
    }
    return result;
}
 
Example 2
Source File: AttachmentPointWidget.java    From talos with Apache License 2.0 5 votes vote down vote up
@Override
public Actor getSubWidget() {
    attachmentPointBox = new AttachmentPointBox(TalosMain.Instance().UIStage().getSkin(), "position");

    Array<String> boneNameList = new Array<>();
    boneNameList.clear();
    for(Bone bone: getBoneList()) {
        boneNameList.add(bone.getData().getName());
    }

    attachmentPointBox.setBoneList(boneNameList);
    return attachmentPointBox;
}
 
Example 3
Source File: SpawnController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void autoPlace() {
    if (placed.size > 0) {
        ObjectSet<Creature> tmp = Pools.obtain(ObjectSet.class);
        tmp.addAll(placed);
        for (Creature c : tmp) {
            removeFromPlaced(c);
        }
        tmp.clear();
        Pools.free(tmp);
    }
    Array<Grid2D.Coordinate> coordinates = Pools.obtain(Array.class);
    Set<Map.Entry<Grid2D.Coordinate, Fraction>> spawns = world.level.getElements(LevelElementType.spawn);
    for (Map.Entry<Grid2D.Coordinate, Fraction> e : spawns) {
        if (e.getValue() == world.viewer.fraction) {
            coordinates.add(e.getKey());
        }
    }
    coordinates.shuffle();
    int usedCount = Math.min(creatures.size, coordinates.size);
    Array<Creature> toPlace = Pools.obtain(Array.class);
    toPlace.addAll(creatures);
    toPlace.shuffle();
    toPlace.truncate(usedCount);
    for (Creature creature : toPlace) {
        Grid2D.Coordinate coordinate = coordinates.pop();
        place(creature, coordinate.x(), coordinate.y());
    }
    toPlace.clear();
    coordinates.clear();
    Pools.free(toPlace);
    Pools.free(coordinates);
}
 
Example 4
Source File: ValueArrayMap.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
/** Warning: returned array will be reused! */
public Array<K> getKeys() {
    Array<K> result = tmpKeyArray;
    result.clear();

    for (K key : map.keySet()) {
        result.add(key);
    }
    return result;
}
 
Example 5
Source File: MapGraph.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public Array<Point2> getNeighbors(Point2 src, int flags, Array<Point2> neighbors) {
  neighbors.clear();
  tryNeighbor(neighbors, flags, src.x - 1, src.y    );
  tryNeighbor(neighbors, flags, src.x    , src.y - 1);
  tryNeighbor(neighbors, flags, src.x    , src.y + 1);
  tryNeighbor(neighbors, flags, src.x + 1, src.y    );

  tryNeighbor(neighbors, flags, src.x - 1, src.y - 1);
  tryNeighbor(neighbors, flags, src.x - 1, src.y + 1);
  tryNeighbor(neighbors, flags, src.x + 1, src.y - 1);
  tryNeighbor(neighbors, flags, src.x + 1, src.y + 1);
  return neighbors;
}
 
Example 6
Source File: OperationSystem.java    From artemis-odb-orion with Apache License 2.0 5 votes vote down vote up
private static void clear(Array<OperationTree> operations) {
	for (int i = 0; i < operations.size; i++) {
		operations.get(i).clear();
	}

	operations.clear();
}
 
Example 7
Source File: TabPanel.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public void clear() {
	Array<Button> buttons = buttonGroup.getButtons();
	
	buttons.clear();		
	header.clear();
	tabs.clear();
	body.setActor(null);
	body.clear();
}
 
Example 8
Source File: VfxManager.java    From gdx-vfx with Apache License 2.0 4 votes vote down vote up
/** Applies the effect chain. */
public void applyEffects() {
    if (capturing) {
        throw new IllegalStateException("You should call VfxManager.endCapture() before applying the effects.");
    }

    if (disabled) return;

    Array<ChainVfxEffect> effectChain = filterEnabledEffects(tmpEffectArray);
    if (effectChain.size == 0) {
        effectChain.clear();
        return;
    }

    applyingEffects = true;

    // Enable blending to preserve buffer's alpha values.
    if (blendingEnabled) {
        Gdx.gl.glEnable(GL20.GL_BLEND);
    }

    Gdx.gl.glDisable(GL20.GL_CULL_FACE);
    Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);

    pingPongWrapper.swap(); // Swap buffers to get the input buffer in the src buffer.
    pingPongWrapper.begin();

    // Render the effect chain.
    for (int i = 0; i < effectChain.size; i++) {
        ChainVfxEffect effect = effectChain.get(i);
        effect.render(context, pingPongWrapper);
        if (i < effectChain.size - 1) {
            pingPongWrapper.swap();
        }
    }
    effectChain.clear();
    pingPongWrapper.end();

    // Ensure default texture unit #0 is active.
    Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);

    if (blendingEnabled) {
        Gdx.gl.glDisable(GL20.GL_BLEND);
    }

    applyingEffects = false;
}
 
Example 9
Source File: MultiPool.java    From artemis-odb-orion with Apache License 2.0 4 votes vote down vote up
static final Array<Operation> toRemoveArray() {
	Array<Operation> toRemove = context.get().toRemove;
	toRemove.clear();
	return toRemove;
}
 
Example 10
Source File: ScopePanel.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public void clear() {
	Array<TextButton> buttons = buttonGroup.getButtons();
	
	buttons.clear();		
	hPanel.clear();
}