Java Code Examples for com.badlogic.gdx.utils.Array#removeIndex()
The following examples show how to use
com.badlogic.gdx.utils.Array#removeIndex() .
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: TalosAssetProvider.java From talos with Apache License 2.0 | 6 votes |
public Sprite replaceRegion (FileHandle handle) { Texture texture = new Texture(handle); final Sprite textureRegion = new Sprite(texture); final Array<TextureAtlas.AtlasRegion> regions = atlas.getRegions(); for (int i = 0; i < regions.size; i++) { if (regions.get(i).name.equalsIgnoreCase(handle.nameWithoutExtension())) { regions.removeIndex(i); break; } } atlas.addRegion(handle.nameWithoutExtension(), textureRegion); return textureRegion; }
Example 2
Source File: MaxRectsPacker.java From gdx-texture-packer-gui with Apache License 2.0 | 6 votes |
private void pruneFreeList () { // Go through each pair and remove any rectangle that is redundant. Array<Rect> freeRectangles = this.freeRectangles; for (int i = 0, n = freeRectangles.size; i < n; i++) for (int j = i + 1; j < n; ++j) { Rect rect1 = freeRectangles.get(i); Rect rect2 = freeRectangles.get(j); if (isContainedIn(rect1, rect2)) { freeRectangles.removeIndex(i); --i; --n; break; } if (isContainedIn(rect2, rect1)) { freeRectangles.removeIndex(j); --j; --n; } } }
Example 3
Source File: SpineRenderer.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
@Override public String[] getInternalAnimations(AnimationDesc anim) { try { retrieveSource(anim.source, ((SpineAnimationDesc) anim).atlas); } catch (GdxRuntimeException e) { sourceCache.remove(anim.source); Array<String> dependencies = EngineAssetManager.getInstance().getDependencies(getFileName(anim.source)); if (dependencies.size > 0) dependencies.removeIndex(dependencies.size - 1); return new String[0]; } Array<Animation> animations = ((SkeletonCacheEntry) sourceCache.get(anim.source)).skeleton.getData() .getAnimations(); String[] result = new String[animations.size]; for (int i = 0; i < animations.size; i++) { Animation a = animations.get(i); result[i] = a.getName(); } return result; }
Example 4
Source File: LayerList.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
private void up() { int pos = list.getSelectedIndex(); if (pos == -1 || pos == 0) return; Array<SceneLayer> items = list.getItems(); SceneLayer e = items.get(pos); SceneLayer e2 = items.get(pos - 1); parent.getLayers().set(pos, e2); parent.getLayers().set(pos - 1, e); items.removeIndex(pos); items.insert(pos - 1, e); list.setSelectedIndex(pos - 1); upBtn.setDisabled(list.getSelectedIndex() == 0); downBtn.setDisabled(list.getSelectedIndex() == list.getItems().size - 1); Ctx.project.setModified(); }
Example 5
Source File: LayerList.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
private void down() { int pos = list.getSelectedIndex(); Array<SceneLayer> items = list.getItems(); if (pos == -1 || pos == items.size - 1) return; SceneLayer e = items.get(pos); SceneLayer e2 = pos + 1 < items.size ? items.get(pos + 1) : null; parent.getLayers().set(pos, e2); parent.getLayers().set(pos + 1, e); items.removeIndex(pos); items.insert(pos + 1, e); list.setSelectedIndex(pos + 1); upBtn.setDisabled(list.getSelectedIndex() == 0); downBtn.setDisabled(list.getSelectedIndex() == list.getItems().size - 1); Ctx.project.setModified(); }
Example 6
Source File: Event.java From uracer-kotd with Apache License 2.0 | 5 votes |
public void removeListener (Listener<T, O> listener, T type, O order) { Array<Listener<T, O>> ls = listeners[type.ordinal()][order.ordinal()]; int pos = ls.indexOf(listener, true); if (pos > -1) { ls.removeIndex(pos); } }
Example 7
Source File: Moveset.java From Unlucky with MIT License | 5 votes |
/** * Returns a Move array with 4 unique moves chosen from all possible Moves * * @return */ private Move[] getRandomMoves() { Array<Move> all = new Array<Move>(); all.addAll(rm.accurateMoves); all.addAll(rm.wideMoves); all.addAll(rm.critMoves); all.addAll(rm.healMoves); Move[] ret = new Move[4]; int index; for (int i = 0; i < ret.length; i++) { index = MathUtils.random(all.size - 1); Move randMove = all.get(index); Move temp = null; if (randMove.type < 2) temp = new Move(randMove.type, randMove.name, randMove.minDamage, randMove.maxDamage); else if (randMove.type == 2) temp = new Move(randMove.name, randMove.minDamage, randMove.crit); else if (randMove.type == 3) temp = new Move(randMove.name, randMove.minHeal, randMove.maxHeal, randMove.dmgReduction); ret[i] = temp; all.removeIndex(index); } return ret; }
Example 8
Source File: PvpMessageListener.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private void checkQueue(IParticipant from) { Array<IPvpMessage> messages = queue.get(from); if (messages == null || messages.size == 0) return; int neededIndex = receivedMessagesIndexes.get(from, 0); if (messages.first().packetIdx == neededIndex) { IPvpMessage m = messages.removeIndex(0); receiveMessage(from, m); checkQueue(from); } }
Example 9
Source File: AnimationDrawable.java From TerraLegion with MIT License | 5 votes |
private static void addMiddleReversed(Array<TextureRegion> frames, boolean keepFirst) { if (frames.size < 3) { return; } Array<TextureRegion> middleReversed = new Array<TextureRegion>(frames); if (!keepFirst) { middleReversed.removeIndex(0); } middleReversed.removeIndex(middleReversed.size - 1); middleReversed.reverse(); frames.addAll(middleReversed); }
Example 10
Source File: Box2DMapObjectParser.java From Entitas-Java with MIT License | 5 votes |
/** * creates {@link Fixture Fixtures} from a {@link MapObject} * * @param mapObject the {@link MapObject} to parse * @return an array of parsed {@link Fixture Fixtures} */ public Fixture[] createFixtures(MapObject mapObject) { Polygon polygon; if (!(mapObject instanceof PolygonMapObject) || isConvex(polygon = ((PolygonMapObject) mapObject).getPolygon())) return new Fixture[]{createFixture(mapObject)}; Polygon[] convexPolygons; if (triangulate) { if (areVerticesClockwise(polygon)) { // ensure the vertices are in counterclockwise order (not really necessary according to EarClippingTriangulator's javadoc, but sometimes better) Array<Vector2> vertices = new Array<Vector2>(toVector2Array(polygon.getVertices())); Vector2 first = vertices.removeIndex(0); vertices.reverse(); vertices.insert(0, first); polygon.setVertices(toFloatArray(vertices.items)); } convexPolygons = toPolygonArray(toVector2Array(new EarClippingTriangulator().computeTriangles(polygon.getTransformedVertices()).toArray()), 3); } else { Array<Array<Vector2>> convexPolys = BayazitDecomposer.convexPartition(new Array<Vector2>(toVector2Array(polygon.getTransformedVertices()))); convexPolygons = new Polygon[convexPolys.size]; for (int i = 0; i < convexPolygons.length; i++) convexPolygons[i] = new Polygon(toFloatArray((Vector2[]) convexPolys.get(i).toArray(Vector2.class))); } // create the fixtures using the convex polygons Fixture[] fixtures = new Fixture[convexPolygons.length]; for (int i = 0; i < fixtures.length; i++) { PolygonMapObject convexObject = new PolygonMapObject(convexPolygons[i]); convexObject.setColor(mapObject.getColor()); convexObject.setName(mapObject.getName()); convexObject.setOpacity(mapObject.getOpacity()); convexObject.setVisible(mapObject.isVisible()); convexObject.getProperties().putAll(mapObject.getProperties()); fixtures[i] = createFixture(convexObject); } return fixtures; }
Example 11
Source File: Box2DMapObjectParser.java From Entitas-Java with MIT License | 5 votes |
/** * creates {@link Fixture Fixtures} from a {@link MapObject} * * @param mapObject the {@link MapObject} to parse * @return an array of parsed {@link Fixture Fixtures} */ public Fixture[] createFixtures(MapObject mapObject) { Polygon polygon; if (!(mapObject instanceof PolygonMapObject) || isConvex(polygon = ((PolygonMapObject) mapObject).getPolygon())) return new Fixture[]{createFixture(mapObject)}; Polygon[] convexPolygons; if (triangulate) { if (areVerticesClockwise(polygon)) { // ensure the vertices are in counterclockwise order (not really necessary according to EarClippingTriangulator's javadoc, but sometimes better) Array<Vector2> vertices = new Array<Vector2>(toVector2Array(polygon.getVertices())); Vector2 first = vertices.removeIndex(0); vertices.reverse(); vertices.insert(0, first); polygon.setVertices(toFloatArray(vertices.items)); } convexPolygons = toPolygonArray(toVector2Array(new EarClippingTriangulator().computeTriangles(polygon.getTransformedVertices()).toArray()), 3); } else { Array<Array<Vector2>> convexPolys = BayazitDecomposer.convexPartition(new Array<Vector2>(toVector2Array(polygon.getTransformedVertices()))); convexPolygons = new Polygon[convexPolys.size]; for (int i = 0; i < convexPolygons.length; i++) convexPolygons[i] = new Polygon(toFloatArray((Vector2[]) convexPolys.get(i).toArray(Vector2.class))); } // create the fixtures using the convex polygons Fixture[] fixtures = new Fixture[convexPolygons.length]; for (int i = 0; i < fixtures.length; i++) { PolygonMapObject convexObject = new PolygonMapObject(convexPolygons[i]); convexObject.setColor(mapObject.getColor()); convexObject.setName(mapObject.getName()); convexObject.setOpacity(mapObject.getOpacity()); convexObject.setVisible(mapObject.isVisible()); convexObject.getProperties().putAll(mapObject.getProperties()); fixtures[i] = createFixture(convexObject); } return fixtures; }
Example 12
Source File: OperationSystem.java From artemis-odb-orion with Apache License 2.0 | 5 votes |
private void process(Array<OperationTree> operations) { for (int i = 0; operations.size > i; i++) { OperationTree ot = operations.get(i); ot.act(world.delta); if (ot.isComplete()) { OperationTree node = operations.removeIndex(i--); node.clear(); } } }
Example 13
Source File: BoundedSlotAssignmentStrategy.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public void removeSlotAssignment (Array<SlotAssignment<T>> assignments, int index) { int sn = assignments.get(index).slotNumber; for (int i = 0; i < assignments.size; i++) { SlotAssignment<T> sa = assignments.get(i); if (sa.slotNumber >= sn) sa.slotNumber--; } assignments.removeIndex(index); }
Example 14
Source File: FreeSlotAssignmentStrategy.java From gdx-ai with Apache License 2.0 | 4 votes |
@Override public void removeSlotAssignment (Array<SlotAssignment<T>> assignments, int index) { assignments.removeIndex(index); }