本文整理汇总了Java中com.badlogic.gdx.utils.IntArray类的典型用法代码示例。如果您正苦于以下问题:Java IntArray类的具体用法?Java IntArray怎么用?Java IntArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntArray类属于com.badlogic.gdx.utils包,在下文中一共展示了IntArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
public Cave generate() {
int spawnDist = (int) distanceFromSpawn(caveStartX, caveStartZ);
Log.debug("Generating new cave at " + caveStartX + "," + caveStartZ + " (" + spawnDist + " blocks from spawn)");
generateNodes();
calculateBlocks();
Cave cave = new Cave(caveStartX, caveStartY, caveStartZ, new HashMap<AreaReference, int[]>() {
{
for (Map.Entry<AreaReference, IntArray> entry : blocks.entrySet()) {
this.put(entry.getKey(), entry.getValue().toArray());
}
}
});
return cave;
}
示例2: getEntitiesInArea
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
/**
* Sandbox method for returning the entities in an area
*
* @param mid center of the area to search
* @param start left upper corner relative to the center
* @param end right lower corner relative to the center
* @return entities in area
*/
protected IntArray getEntitiesInArea(Vector2 mid, Vector2 start, Vector2 end) {
IntArray array = new IntArray();
for (float x = mid.x + Math.min(start.x, end.x); x <= mid.x + Math.max(start.x, end.x); x++) {
for (float y = mid.y + Math.min(start.y, end.y); y <= mid.y + Math.max(start.y, end.y); y++) {
try {
Tile t = arcadeWorld.getTile((int) x, (int) y);
if (t.getEntities().size != 0)
array.add(t.getEntities().first());
} catch (IndexOutOfBoundsException ex) {
continue;
}
}
}
return array;
}
示例3: QuadTree
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
/**
* create a quadtree collision manager with a default max_depth of 4 and a
* max_object count of 10.
*
* @param x
* @param y
* @param width
* @param height
*/
public QuadTree(float x, float y, float width, float height) {
check_object = new BasicGameObject();
check_object.init(null);
remove_objects = new IntArray();
culling = true;
follow_x =0;
follow_y =0;
bounds = new Rectangle(x - PAD, y - PAD, width + PAD * 2, height + PAD * 2);
objects = new Array<GameObject>();
follow_view = false;
final QuadTree m = this;
quad_pool = new Pool<QuadTree.Quad>() {
@Override
protected Quad newObject() {
return new Quad(m);
}
};
max_depth = 4;
max_objects = 10;
root = quad_pool.obtain();
root.init(null, 0, bounds.x, bounds.y, bounds.width, bounds.height);
ret_list = new Array<GameObject>();
}
示例4: fetchHighScores
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
public static IntArray fetchHighScores() {
Preferences prefs = Gdx.app.getPreferences(PREFERENCES_NAME);
IntArray scores = new IntArray();
for (int i = 0; i < MAX_NR_SCORES; i++) {
int score = prefs.getInteger(PREFERENCES_SCORE_NAME + i, -1);
if (score == -1) {
break;
}
scores.add(score);
}
return scores;
}
示例5: readVertices
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
private Vertices readVertices (DataInput input, int vertexCount) throws IOException {
int verticesLength = vertexCount << 1;
Vertices vertices = new Vertices();
if (!input.readBoolean()) {
vertices.vertices = readFloatArray(input, verticesLength, scale);
return vertices;
}
FloatArray weights = new FloatArray(verticesLength * 3 * 3);
IntArray bonesArray = new IntArray(verticesLength * 3);
for (int i = 0; i < vertexCount; i++) {
int boneCount = input.readInt(true);
bonesArray.add(boneCount);
for (int ii = 0; ii < boneCount; ii++) {
bonesArray.add(input.readInt(true));
weights.add(input.readFloat() * scale);
weights.add(input.readFloat() * scale);
weights.add(input.readFloat());
}
}
vertices.vertices = weights.toArray();
vertices.bones = bonesArray.toArray();
return vertices;
}
示例6: readVertices
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
private void readVertices (JsonValue map, VertexAttachment attachment, int verticesLength) {
attachment.setWorldVerticesLength(verticesLength);
float[] vertices = map.require("vertices").asFloatArray();
if (verticesLength == vertices.length) {
if (scale != 1) {
for (int i = 0, n = vertices.length; i < n; i++)
vertices[i] *= scale;
}
attachment.setVertices(vertices);
return;
}
FloatArray weights = new FloatArray(verticesLength * 3 * 3);
IntArray bones = new IntArray(verticesLength * 3);
for (int i = 0, n = vertices.length; i < n;) {
int boneCount = (int)vertices[i++];
bones.add(boneCount);
for (int nn = i + boneCount * 4; i < nn; i += 4) {
bones.add((int)vertices[i]);
weights.add(vertices[i + 1] * scale);
weights.add(vertices[i + 2] * scale);
weights.add(vertices[i + 3]);
}
}
attachment.setBones(bones.toArray());
attachment.setVertices(weights.toArray());
}
示例7: calchull
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
private int calchull (ObjectArrayList<Vector3> verts, int verts_count, IntArray tris_out, int[] tris_count, int vlimit) {
int rc = calchullgen(verts, verts_count, vlimit);
if (rc == 0) return 0;
IntArray ts = new IntArray();
for (int i = 0; i < tris.size(); i++) {
if (tris.getQuick(i) != null) {
for (int j = 0; j < 3; j++) {
ts.add((tris.getQuick(i)).getCoord(j));
}
deAllocateTriangle(tris.getQuick(i));
}
}
tris_count[0] = ts.size / 3;
MiscUtil.resize(tris_out, ts.size, 0);
for (int i = 0; i < ts.size; i++) {
tris_out.set(i, ts.get(i));
}
MiscUtil.resize(tris, 0, NEW_TRI_SUPPLIER);
return 1;
}
示例8: BitmapFontCache
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
/** @param integer If true, rendering positions will be at integer values to avoid filtering artifacts. */
public BitmapFontCache (BitmapFont font, boolean integer) {
this.font = font;
this.integer = integer;
int pageCount = font.regions.size;
if (pageCount == 0) throw new IllegalArgumentException("The specified font must contain at least one texture page.");
pageVertices = new float[pageCount][];
idx = new int[pageCount];
if (pageCount > 1) {
// Contains the indices of the glyph in the cache as they are added.
pageGlyphIndices = new IntArray[pageCount];
for (int i = 0, n = pageGlyphIndices.length; i < n; i++)
pageGlyphIndices[i] = new IntArray();
}
tempGlyphCount = new int[pageCount];
}
示例9: getKeys
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
protected int[] getKeys(Mode mode, boolean containsScratch) {
int key = (getModifyTarget() == SIDE_2P)
? mode.key / mode.player
: 0;
if (key == mode.key) {
return new int[0];
} else {
IntArray keys = new IntArray();
for (int i = 0; i < mode.key / mode.player; i++) {
if (containsScratch || !mode.isScratchKey(key + i)) {
keys.add(key + i);
}
}
return keys.toArray();
}
}
示例10: getTilesFromPolygon
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
private IntArray getTilesFromPolygon(Polygon polygon) {
IntArray tiles = new IntArray();
Polygon transformedPolygon = transformTiledPolygon(gameMap, polygon);
Rectangle rectangle = transformedPolygon.getBoundingRectangle();
int startX = (int) rectangle.getX();
int startY = (int) rectangle.getY();
int endX = startX + (int) rectangle.getWidth();
int endY = startY + (int) rectangle.getHeight();
for (int x = startX; x <= endX; ++x) {
for (int y = startY; y <= endY; ++y) {
if (transformedPolygon.contains(x, y)) {
tiles.add(x);
tiles.add(y);
}
}
}
return tiles;
}
示例11: sort
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
/** Sorts x,y pairs of values by the x value, then the y value.
* @param count Number of indices, must be even. */
private void sort (float[] values, int count) {
int lower = 0;
int upper = count - 1;
IntArray stack = quicksortStack;
stack.add(lower);
stack.add(upper - 1);
while (stack.size > 0) {
upper = stack.pop();
lower = stack.pop();
if (upper <= lower) continue;
int i = quicksortPartition(values, lower, upper);
if (i - lower > upper - i) {
stack.add(lower);
stack.add(i - 2);
}
stack.add(i + 2);
stack.add(upper);
if (upper - i >= i - lower) {
stack.add(lower);
stack.add(i - 2);
}
}
}
示例12: load
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
@Override
public void load (AssetManager manager, ResourceData resources) {
SaveData data = resources.getSaveData();
Array<IntArray>effectsIndices = data.load("indices");
AssetDescriptor descriptor;
Iterator<IntArray> iterator = effectsIndices.iterator();
while((descriptor = data.loadAsset()) != null){
ParticleEffect effect = (ParticleEffect)manager.get(descriptor);
if(effect == null)
throw new RuntimeException("Template is null");
Array<ParticleController> effectControllers = effect.getControllers();
IntArray effectIndices = iterator.next();
for (int i = 0, n = effectIndices.size; i < n; i++) {
templates.add(effectControllers.get(effectIndices.get(i)));
}
}
}
示例13: BitmapFontCache
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
/** @param integer If true, rendering positions will be at integer values to avoid filtering artifacts. */
public BitmapFontCache (BitmapFont font, boolean integer) {
this.font = font;
this.integer = integer;
int regionsLength = font.regions.length;
if (regionsLength == 0) throw new IllegalArgumentException("The specified font must contain at least one texture page.");
this.vertexData = new float[regionsLength][];
this.colorChunks = new Array<ColorChunk>();
this.idx = new int[regionsLength];
int vertexDataLength = vertexData.length;
if (vertexDataLength > 1) { // If we have multiple pages...
// Contains the indices of the glyph in the Cache as they are added.
glyphIndices = new IntArray[vertexDataLength];
for (int i = 0, n = glyphIndices.length; i < n; i++) {
glyphIndices[i] = new IntArray();
}
tmpGlyphCount = new int[vertexDataLength];
}
}
示例14: fillTable
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
@Override
protected void fillTable (final Table table) {
final IntArray rowSizes = getRowSizes();
final int widgetsInRow = getLowestCommonMultiple(rowSizes);
for (int rowIndex = 0, widgetIndex = 0; rowIndex < rowSizes.size; rowIndex++) {
final int rowSize = rowSizes.get(rowIndex);
final int currentWidgetColspan = widgetsInRow / rowSize;
boolean isFirst = shouldExpand(rowSize);
for (final int totalWidgetsBeforeRowEnd = widgetIndex + rowSize; widgetIndex < totalWidgetsBeforeRowEnd; widgetIndex++) {
final Cell<?> cell =
getWidget(widgetIndex).buildCell(table, getDefaultWidgetPadding()).colspan(
currentWidgetColspan);
// Keeping widgets together - expanding X for first and last widget, setting alignments:
if (isFirst) {
isFirst = false;
cell.expandX().right();
} else if (isLast(widgetIndex, rowSize, totalWidgetsBeforeRowEnd)) {
cell.expandX().left();
}
}
table.row();
}
}
示例15: TabRecipeList
import com.badlogic.gdx.utils.IntArray; //导入依赖的package包/类
public TabRecipeList(GuiBase gui, IntArray indicies) {
super(gui, LEFT);
this.indicies = indicies;
this.maxHeight = 115;
ListBoxElementText text;
int max = 0;
for (Recipe recipe : UpgradeRegistry.getRecipeList()) {
text = new ListBoxElementText(StringHelper.localize(recipe.getRecipeOutput().getName()));
max = Math.max(text.getWidth(), max);
}
this.list = new ElementUpgradeListBox(this.gui, 7, 7, max, 100) {
public void onUpgradeSelected(IUpgrade upgrade, int index) {
TabRecipeList.this.onUpgradeSelected(upgrade, index);
}
};
this.maxWidth = Math.min(max + 12, 132);
this.addElement(list);
}