当前位置: 首页>>代码示例>>Java>>正文


Java Array.removeIndex方法代码示例

本文整理汇总了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;
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:22,代码来源:EventDispatcher.java

示例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);
    	}
    }
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:17,代码来源:EventDispatcher.java

示例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;
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:16,代码来源:Balanceball.java

示例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);
}
 
开发者ID:chrisj42,项目名称:miniventure,代码行数:46,代码来源:Tile.java


注:本文中的com.badlogic.gdx.utils.Array.removeIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。