Java Code Examples for com.badlogic.gdx.utils.Array#indexOf()
The following examples show how to use
com.badlogic.gdx.utils.Array#indexOf() .
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: DragPane.java From vis-ui with Apache License 2.0 | 6 votes |
/** * @param actor is being dragged. * @param dragPane is under the actor. Stores a {@link HorizontalGroup}. * @param directPaneChild actor under the cursor. * @return true if actor was accepted by the group. */ protected boolean addToHorizontalGroup (final Actor actor, final DragPane dragPane, final Actor directPaneChild) { final Array<Actor> children = dragPane.getChildren(); final int indexOfDraggedActor = children.indexOf(actor, true); actor.remove(); if (indexOfDraggedActor >= 0) { final int indexOfDirectChild = children.indexOf(directPaneChild, true); if (indexOfDirectChild > indexOfDraggedActor) { dragPane.addActorAfter(directPaneChild, actor); } else { dragPane.addActorBefore(directPaneChild, actor); } } else if (DRAG_POSITION.x > directPaneChild.getWidth() / 2f) { dragPane.addActorAfter(directPaneChild, actor); } else { dragPane.addActorBefore(directPaneChild, actor); } return APPROVE; }
Example 2
Source File: DragPane.java From vis-ui with Apache License 2.0 | 6 votes |
/** * @param actor is being dragged. * @param dragPane is under the actor. Stores a {@link VerticalGroup}. * @param directPaneChild actor under the cursor. * @return true if actor was accepted by the group. */ protected boolean addToVerticalGroup (final Actor actor, final DragPane dragPane, final Actor directPaneChild) { final Array<Actor> children = dragPane.getChildren(); final int indexOfDraggedActor = children.indexOf(actor, true); actor.remove(); if (indexOfDraggedActor >= 0) { final int indexOfDirectChild = children.indexOf(directPaneChild, true); if (indexOfDirectChild > indexOfDraggedActor) { dragPane.addActorAfter(directPaneChild, actor); } else { dragPane.addActorBefore(directPaneChild, actor); } } else if (DRAG_POSITION.y < directPaneChild.getHeight() / 2f) { // Y inverted. dragPane.addActorAfter(directPaneChild, actor); } else { dragPane.addActorBefore(directPaneChild, actor); } return APPROVE; }
Example 3
Source File: GLTFExporter.java From gdx-gltf with Apache License 2.0 | 5 votes |
/** multi scene export */ public void export(Array<SceneModel> scenes, SceneModel defaultScene, FileHandle file) { beginMultiScene(file); for(SceneModel scene : scenes){ GLTFScene glScene = obtainScene(); exportScene(glScene, scene); } root.scene = scenes.indexOf(defaultScene, true); if(root.scene < 0) throw new GdxRuntimeException("scene not found"); end(file); }
Example 4
Source File: GLTFExporter.java From gdx-gltf with Apache License 2.0 | 5 votes |
/** multi scene export */ public void export(Array<Scene> scenes, Scene defaultScene, FileHandle file) { beginMultiScene(file); for(Scene scene : scenes){ GLTFScene glScene = obtainScene(); exportScene(glScene, scene); } root.scene = scenes.indexOf(defaultScene, true); if(root.scene < 0) throw new GdxRuntimeException("scene not found"); end(file); }
Example 5
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 6
Source File: ModelUtils.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
public void movePackTop(PackModel pack) { ensurePackExists(pack); Array<PackModel> packs = getProject().getPacks(); // Check if pack is already at the top if (packs.indexOf(pack, true) == 0) return; packs.removeValue(pack, true); packs.insert(0, pack); eventDispatcher.postEvent(new PackListOrderChangedEvent()); }
Example 7
Source File: ModelUtils.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
public void movePackBottom(PackModel pack) { ensurePackExists(pack); Array<PackModel> packs = getProject().getPacks(); int idx = packs.indexOf(pack, true); // Check if pack is already at the bottom if (idx == packs.size-1) return; packs.removeValue(pack, true); packs.insert(packs.size-1, pack); eventDispatcher.postEvent(new PackListOrderChangedEvent()); }
Example 8
Source File: ModelUtils.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
public void movePackUp(PackModel pack) { ensurePackExists(pack); Array<PackModel> packs = getProject().getPacks(); int idx = packs.indexOf(pack, true); // Check if pack is already at the top if (idx == 0) return; packs.swap(idx, idx - 1); eventDispatcher.postEvent(new PackListOrderChangedEvent()); }
Example 9
Source File: ModelUtils.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
public void movePackDown(PackModel pack) { ensurePackExists(pack); Array<PackModel> packs = getProject().getPacks(); int idx = packs.indexOf(pack, true); // Check if pack is already at the bottom if (idx == packs.size-1) return; packs.swap(idx, idx + 1); eventDispatcher.postEvent(new PackListOrderChangedEvent()); }
Example 10
Source File: ModelUtils.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
public void movePackNextTo(PackModel anchor, PackModel pack) { ensurePackExists(anchor); ensurePackExists(pack); Array<PackModel> packs = getProject().getPacks(); int idxAnchor = packs.indexOf(anchor, true); int idxPack = packs.indexOf(pack, true); // Check if pack is already next to anchor if (idxAnchor-idxPack == -1) return; packs.removeValue(pack, true); packs.insert(idxAnchor+1, pack); eventDispatcher.postEvent(new PackListOrderChangedEvent()); }
Example 11
Source File: ModelUtils.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
public void movePackPrevTo(PackModel anchor, PackModel pack) { ensurePackExists(anchor); ensurePackExists(pack); Array<PackModel> packs = getProject().getPacks(); int idxAnchor = packs.indexOf(anchor, true); int idxPack = packs.indexOf(pack, true); // Check if pack is already previous to anchor if (idxAnchor-idxPack == 1) return; packs.removeValue(pack, true); packs.insert(idxAnchor, pack); eventDispatcher.postEvent(new PackListOrderChangedEvent()); }
Example 12
Source File: ModelUtils.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
/** * Selects previous pack. If there is no previous pack, selects next pack */ public void selectClosestPack(PackModel pack) { ensurePackExists(pack); Array<PackModel> packs = getProject().getPacks(); int index = packs.indexOf(pack, true); if (index > 0) { selectPrevPack(pack); } else { selectNextPack(pack); } }
Example 13
Source File: DragPane.java From vis-ui with Apache License 2.0 | 5 votes |
/** * @param actor is being dragged. * @param dragPane is under the actor. Stores a {@link GridGroup} or unknown group. * @param directPaneChild actor under the cursor. * @return true if actor was accepted by the group. */ protected boolean addToOtherGroup (final Actor actor, final DragPane dragPane, final Actor directPaneChild) { final Array<Actor> children = dragPane.getChildren(); final int indexOfDirectChild = children.indexOf(directPaneChild, true); final int indexOfDraggedActor = children.indexOf(actor, true); actor.remove(); if (indexOfDraggedActor >= 0) { // Dragging own actor. if (indexOfDraggedActor > indexOfDirectChild) { // Dropped after current position. dragPane.addActorBefore(directPaneChild, actor); } else { // Dropped before current position. dragPane.addActorAfter(directPaneChild, actor); } } else if (indexOfDirectChild == children.size - 1) { // Dragged into last element. if (DRAG_POSITION.y < directPaneChild.getHeight() / 2f || DRAG_POSITION.x > directPaneChild.getWidth() / 2f) { // Adding last: // last: dragPane.addActor(actor); } else { dragPane.addActorBefore(directPaneChild, actor); } } else if (indexOfDirectChild == 0) { // Dragged into first element. if (DRAG_POSITION.y < directPaneChild.getHeight() / 2f || DRAG_POSITION.x > directPaneChild.getWidth() / 2f) { dragPane.addActorAfter(directPaneChild, actor); } else { // Adding first: dragPane.addActorBefore(directPaneChild, actor); } } else { // Replacing hovered actor: dragPane.addActorBefore(directPaneChild, actor); } return APPROVE; }
Example 14
Source File: AfterAction.java From Scene3d with Apache License 2.0 | 5 votes |
@Override protected boolean delegate (float delta) { Array<Action3d> currentActions = actor3d.getActions3d(); if (currentActions.size == 1) waitForActions.clear(); for (int i = waitForActions.size - 1; i >= 0; i--) { Action3d action = waitForActions.get(i); int index = currentActions.indexOf(action, true); if (index == -1) waitForActions.removeIndex(i); } if (waitForActions.size > 0) return false; return action.act(delta); }