當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。