Java Code Examples for com.watabou.utils.SparseArray#get()

The following examples show how to use com.watabou.utils.SparseArray#get() . 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: Level.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
public LevelObject getTopLevelObject(int pos) {
	LevelObject top = null;

	for (int i = 0; i < objects.size(); i++) {
		SparseArray<LevelObject> objectLayer = objects.valueAt(i);

		LevelObject candidate = objectLayer.get(pos);
		if (top == null) {
			top = candidate;
		} else {
			if (candidate != null && candidate.getLayer() > top.getLayer()) {
				top = candidate;
			}
		}
	}
	return top;
}
 
Example 2
Source File: Level.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
public LevelObject getLevelObject(int pos, int layer) {
	SparseArray<LevelObject> objectsLayer = objects.get(layer);
	if (objectsLayer == null) {
		return null;
	}
	return objectsLayer.get(pos);
}