本文整理汇总了Java中com.badlogic.gdx.utils.Array.removeIndex方法的典型用法代码示例。如果您正苦于以下问题:Java Array.removeIndex方法的具体用法?Java Array.removeIndex怎么用?Java Array.removeIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.Array
的用法示例。
在下文中一共展示了Array.removeIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeListenerInVector
import com.badlogic.gdx.utils.Array; //导入方法依赖的package包/类
private boolean removeListenerInVector(Array<EventListener> listeners, EventListener listener) {
if(listeners == null) {return false;}
for(int i = listeners.size - 1; i >= 0; --i) {
EventListener l = listeners.get(i);
if(l == listener) {
l.setRegistered(false);
if(l.getAssociatedNode() != null) {
dissociateNodeAndEventListener(l.getAssociatedNode(), l);
l.setAssociatedNode(null);
}
if(_inDispatch <= 0) {
listeners.removeIndex(i);
} else {
_toRemovedListeners.add(l);
}
return true;
}
}
return false;
}
示例2: removeAllListenersInVector
import com.badlogic.gdx.utils.Array; //导入方法依赖的package包/类
private void removeAllListenersInVector(Array<EventListener> listenerVector) {
if (listenerVector == null) {return;}
for (int i = listenerVector.size - 1; i >= 0; --i) {
EventListener l = listenerVector.get(i);
INode node;
if((node = l.getAssociatedNode()) != null) {
dissociateNodeAndEventListener(node, l);
l.setAssociatedNode(null);
}
if(_inDispatch == 0) {
listenerVector.removeIndex(i);
}
}
}
示例3: updateAverage
import com.badlogic.gdx.utils.Array; //导入方法依赖的package包/类
private float updateAverage(Array<Float> list, float value) {
// this is not very efficient as it will trigger a memcopy every time
if (list.size > INPUT_SAMPLE_SIZE) {
list.removeIndex(0);
}
list.add(value);
float total = 0.f;
for (float gyro : list) {
total += gyro;
}
return total / list.size;
}
示例4: resetTile
import com.badlogic.gdx.utils.Array; //导入方法依赖的package包/类
public void resetTile(@NotNull TileType newType) {
// check for entities that will not be allowed on the new tile, and move them to the closest adjacent tile they are allowed on.
Array<Tile> surroundingTiles = getAdjacentTiles(true);
for(Entity entity: level.getOverlappingEntities(getBounds())) {
// for each entity, check if it can walk on the new tile type. If not, fetch the surrounding tiles, remove those the entity can't walk on, and then fetch the closest tile of the remaining ones.
if(newType.getProp(SolidProperty.class).isPermeableBy(entity)) continue; // no worries for this entity.
Array<Tile> aroundTiles = new Array<>(surroundingTiles);
for(int i = 0; i < aroundTiles.size; i++) {
if(!aroundTiles.get(i).groundType.getProp(SolidProperty.class).isPermeableBy(entity)) {
aroundTiles.removeIndex(i);
i--;
}
}
Tile closest = entity.getClosestTile(aroundTiles);
// if none remain (returned tile is null), take no action for that entity. If a tile is returned, then move the entity to the center of that tile.
if(closest != null)
entity.moveTo(closest);
}
TileType prev = getType();
if(!newType.isGroundTile()) {
// the new type has no defined under type, so the previous tile type should be conserved.
// also, since you should never place one surface tile directly on another surface tile, I can technically assume that the current data array only has the ground tile data. But, since creative mode could be a thing, and it isn't too hard, I'm goinf to double check anyway.
int[] newData = newType.getInitialData();
int groundDataLen = groundType.getDataLength();
int[] fullData = new int[groundDataLen + newData.length];
System.arraycopy(data, 0, fullData, 0, groundDataLen); // copy ground tile data, first
System.arraycopy(newData, 0, fullData, groundDataLen, newData.length); // copy surface tile data
data = fullData;
surfaceType = newType;
}
else { // new type is ground tile, remove surface type if present
data = newType.getInitialData();
surfaceType = null;
groundType = newType;
}
newType.getProp(CoveredTileProperty.class).tilePlaced(this, prev);
}