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


Java IntArray.add方法代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.IntArray.add方法的典型用法代码示例。如果您正苦于以下问题:Java IntArray.add方法的具体用法?Java IntArray.add怎么用?Java IntArray.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.utils.IntArray的用法示例。


在下文中一共展示了IntArray.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:EtherWorks,项目名称:arcadelegends-gg,代码行数:24,代码来源:Character.java

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

示例3: 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;
}
 
开发者ID:laurencegw,项目名称:jenjin,代码行数:24,代码来源:SkeletonBinary.java

示例4: 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());
}
 
开发者ID:laurencegw,项目名称:jenjin,代码行数:27,代码来源:SkeletonJson.java

示例5: 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;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:25,代码来源:HullLibrary.java

示例6: 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();
	}
}
 
开发者ID:exch-bms2,项目名称:beatoraja,代码行数:17,代码来源:PatternModifier.java

示例7: 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;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:19,代码来源:GameMapLoader.java

示例8: 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);
		}
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:ConvexHull.java

示例9: read

import com.badlogic.gdx.utils.IntArray; //导入方法依赖的package包/类
@Override
public IntArray read(Kryo kryo, Input input, Class<IntArray> type) {
    int length = input.readVarInt(true);
    boolean ordered = input.readBoolean();
    IntArray array = new IntArray(ordered, length);
    for (int i = 0; i < length; i++) {
        array.add(input.readInt());
    }
    return array;
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:11,代码来源:IntArraySerializer.java

示例10: spawnEnemies

import com.badlogic.gdx.utils.IntArray; //导入方法依赖的package包/类
/**
 * Extracts the enemy information form the {@link TiledMap}, and spawns them in.
 * Also adds a {@link AIComponent} to the enemies, targeting the player.
 *
 * @param playerId the player to target
 * @return an {@link IntArray} containing all the enemies
 */
public IntArray spawnEnemies(int playerId) {
    String enemies = (String) tiledMap.getProperties().get("enemies");
    IntArray array = new IntArray();
    for (String enemy : enemies.split("-")) {
        String[] parts = enemy.split(";");

        Vector2 pos = new Vector2(Integer.parseInt(parts[0]),
                Integer.parseInt(parts[1]));
        EntityArguments arguments = getArguments(parts[2]);
        PositionComponent.PositionTemplate positionDef = arguments.get("PositionComponent", PositionComponent.PositionTemplate.class);
        positionDef.x = pos.x;
        positionDef.y = pos.y;
        int id = spawn(Entities.Player, arguments);
        StatComponent statComponent = entityWorld.getMapper(StatComponent.class).get(id);
        final float xp = Integer.parseInt(parts[3]);
        statComponent.statEventHandler = (statComponent1, entityId) ->
        {
            StatComponent player = entityWorld.getMapper(StatComponent.class).get(playerId);
            player.addRuntimeStat(StatComponent.RuntimeStat.experience, xp);
            array.removeValue(id);
        };
        statComponent.setFlag(StatComponent.FlagStat.deleteOnDeath, true);
        AIComponent aiComponent = entityWorld.getMapper(AIComponent.class).create(id);
        aiComponent.target = playerId;
        aiComponent.aggroRange = Integer.parseInt(parts[4]);
        array.add(id);
    }
    return array;
}
 
开发者ID:EtherWorks,项目名称:arcadelegends-gg,代码行数:37,代码来源:ArcadeWorld.java

示例11: init

import com.badlogic.gdx.utils.IntArray; //导入方法依赖的package包/类
@Override
public void init(GameObject object) {
	solid_filter = new IntArray();
	solid_filter.add(WALL);
	current_collisions = new IntArray();
	collision_map_tiles = new Array<TilemapLayerObject.MapTile>();
	tile_pool = new Pool<TilemapLayerObject.MapTile>() {
		@Override
		protected MapTile newObject() {
			return new MapTile();
		}
	};
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:14,代码来源:TileCollisionController.java

示例12: OpenALAudio

import com.badlogic.gdx.utils.IntArray; //导入方法依赖的package包/类
public OpenALAudio (int simultaneousSources, int deviceBufferCount, int deviceBufferSize) {
	this.deviceBufferSize = deviceBufferSize;
	this.deviceBufferCount = deviceBufferCount;

	registerSound("ogg", Ogg.Sound.class);
	registerMusic("ogg", Ogg.Music.class);
	registerSound("wav", Wav.Sound.class);
	registerMusic("wav", Wav.Music.class);
	registerSound("mp3", Mp3.Sound.class);
	registerMusic("mp3", Mp3.Music.class);

	try {
		AL.create();
	} catch (LWJGLException ex) {
		noDevice = true;
		ex.printStackTrace();
		return;
	}

	allSources = new IntArray(false, simultaneousSources);
	for (int i = 0; i < simultaneousSources; i++) {
		int sourceID = alGenSources();
		if (alGetError() != AL_NO_ERROR) break;
		allSources.add(sourceID);
	}
	idleSources = new IntArray(allSources);
	soundIdToSource = new LongMap<Integer>();
	sourceToSoundId = new IntMap<Long>();

	FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6)
		.put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).flip();
	alListener(AL_ORIENTATION, orientation);
	FloatBuffer velocity = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
	alListener(AL_VELOCITY, velocity);
	FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
	alListener(AL_POSITION, position);
	
	recentSounds = new OpenALSound[simultaneousSources];
}
 
开发者ID:Xemiru,项目名称:Undertailor,代码行数:40,代码来源:OpenALAudio.java

示例13: resize

import com.badlogic.gdx.utils.IntArray; //导入方法依赖的package包/类
/**
 * Resizes list to exact size, filling with given value when expanding.
 */
public static void resize(IntArray list, int size, int value) {
	while (list.size < size) {
		list.add(value);
	}
	
	while (list.size > size) {
		list.removeIndex(list.size - 1);
	}
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:13,代码来源:MiscUtil.java

示例14: boxQuery

import com.badlogic.gdx.utils.IntArray; //导入方法依赖的package包/类
/**
 * Returns the indices of the primitives in the primitive_manager field.
 */
public boolean boxQuery(AABB box, IntArray collided_results) {
	int curIndex = 0;
	int numNodes = getNodeCount();

	Stack stack = Stack.enter();
	AABB bound = stack.allocAABB();

	while (curIndex < numNodes) {
		getNodeBound(curIndex, bound);

		// catch bugs in tree data

		boolean aabbOverlap = bound.has_collision(box);
		boolean isleafnode = isLeafNode(curIndex);

		if (isleafnode && aabbOverlap) {
			collided_results.add(getNodeData(curIndex));
		}

		if (aabbOverlap || isleafnode) {
			// next subnode
			curIndex++;
		}
		else {
			// skip node
			curIndex += getEscapeNodeIndex(curIndex);
		}
	}
	if (collided_results.size > 0) {
	    stack.leave();
		return true;
	}
	stack.leave();
	return false;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:39,代码来源:GImpactBvh.java

示例15: rayQuery

import com.badlogic.gdx.utils.IntArray; //导入方法依赖的package包/类
/**
 * Returns the indices of the primitives in the primitive_manager field.
 */
public boolean rayQuery(Vector3 ray_dir, Vector3 ray_origin, IntArray collided_results) {
	int curIndex = 0;
	int numNodes = getNodeCount();

	Stack stack = Stack.enter();
	AABB bound = stack.allocAABB();

	while (curIndex < numNodes) {
		getNodeBound(curIndex, bound);

		// catch bugs in tree data

		boolean aabbOverlap = bound.collide_ray(ray_origin, ray_dir);
		boolean isleafnode = isLeafNode(curIndex);

		if (isleafnode && aabbOverlap) {
			collided_results.add(getNodeData(curIndex));
		}

		if (aabbOverlap || isleafnode) {
			// next subnode
			curIndex++;
		}
		else {
			// skip node
			curIndex += getEscapeNodeIndex(curIndex);
		}
	}
	if (collided_results.size > 0) {
	    stack.leave();
		return true;
	}
	stack.leave();
	return false;
}
 
开发者ID:vbousquet,项目名称:libgdx-jbullet,代码行数:39,代码来源:GImpactBvh.java


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