本文整理匯總了Java中com.badlogic.gdx.utils.Array.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Array.add方法的具體用法?Java Array.add怎麽用?Java Array.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.utils.Array
的用法示例。
在下文中一共展示了Array.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createTopTube
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
public static Array<Body> createTopTube(World world, float posX) {
float posY = generateTubePosition();
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.KinematicBody;
bodyDef.position.set(posX, posY);
PolygonShape shape = new PolygonShape();
shape.setAsBox(Constants.TUBE_WIDTH / 2, Constants.TUBE_HEIGHT / 2);
Body bodyTop = world.createBody(bodyDef);
bodyTop.createFixture(shape, 0f);
bodyTop.resetMassData();
shape.dispose();
bodyTop.setLinearVelocity(Constants.TUBE_SPEED, 0.0f);
Array<Body> bodies = new Array<Body>();
bodies.add(bodyTop);
bodies.add(createBottomTube(world, posX, posY));
return bodies;
}
示例2: fetchGameStatesSync
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
/**
* Blocking version of {@link #fetchGameStatesSync()}
*
* @return game states
* @throws IOException
*/
public Array<String> fetchGameStatesSync() throws IOException {
if (!driveApiEnabled)
throw new UnsupportedOperationException();
Array<String> games = new Array<String>();
FileList l = GApiGateway.drive.files().list()
.setSpaces("appDataFolder")
.setFields("files(name)")
.execute();
for (File f : l.getFiles()) {
games.add(f.getName());
}
return games;
}
示例3: getDependencies
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle tmxFile,
com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) {
Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
try {
root = xml.parse(tmxFile);
Element properties = root.getChildByName("properties");
if (properties != null) {
for (Element property : properties.getChildrenByName("property")) {
String name = property.getAttribute("name");
String value = property.getAttribute("value");
if (name.startsWith("atlas")) {
FileHandle atlasHandle = Gdx.files.internal(value);
dependencies.add(new AssetDescriptor(atlasHandle, TextureAtlas.class));
}
}
}
} catch (IOException e) {
throw new GdxRuntimeException("Unable to parse .tmx file.");
}
return dependencies;
}
示例4: createPowerupPickupAnimation
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
private Array<TextureRegion> createPowerupPickupAnimation(){
Array<TextureRegion> animationSequence = new Array<>();
for (int i = 0; i < 8; i++) {
Texture texture;
if (i < 2){
texture = assetService.getTexture(PLAYER_RED);
} else if (i < 4){
texture = assetService.getTexture(PLAYER_GREEN);
} else if (i < 6){
texture = assetService.getTexture(PLAYER_BLUE);
} else {
texture = assetService.getTexture(PLAYER_YELLOW);
}
animationSequence.add(new TextureRegion(texture));
}
return animationSequence;
}
示例5: Trajectory
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
public Trajectory(Orbiter orbiter) {
this.orbiter = orbiter;
int degreeIncrement = 10;
speed = 10;
Array<Orbiter> pathObjects = new Array<Orbiter>();
for(int i = 0; i < 360; i += degreeIncrement) {
Orbiter.OrbiterBlueprint orbiterBlueprint = new Orbiter.OrbiterBlueprint();
orbiterBlueprint.angle = i;
orbiterBlueprint.angularVelocity = speed;
orbiterBlueprint.radius = orbiter.getRadius();
orbiterBlueprint.xTilt = orbiter.getXTilt();
orbiterBlueprint.zTilt = orbiter.getZTilt();
Sprite trajectoryDot = new Sprite(Scene.pixelTexture);
Color color = new Color();
Color.rgba8888ToColor(color, orbiter.getColor());
trajectoryDot.setColor(color);
trajectoryDot.setSize(2, 2);
pathObjects.add(new Orbiter(trajectoryDot, orbiterBlueprint));
}
path = new Ring(pathObjects);
}
示例6: PathConstraint
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
/** Copy constructor. */
public PathConstraint (PathConstraint constraint, Skeleton skeleton) {
if (constraint == null) throw new IllegalArgumentException("constraint cannot be null.");
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
data = constraint.data;
bones = new Array(constraint.bones.size);
for (Bone bone : constraint.bones)
bones.add(skeleton.bones.get(bone.data.index));
target = skeleton.slots.get(constraint.target.data.index);
position = constraint.position;
spacing = constraint.spacing;
rotateMix = constraint.rotateMix;
translateMix = constraint.translateMix;
}
示例7: getAvailablePieces
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
public Array<Piece> getAvailablePieces() {
Array<Piece> result = new Array<Piece>(count);
for (int i = 0; i < count; ++i)
if (pieces[i] != null)
result.add(pieces[i]);
return result;
}
示例8: IkConstraint
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
/** Copy constructor. */
public IkConstraint (IkConstraint constraint, Skeleton skeleton) {
if (constraint == null) throw new IllegalArgumentException("constraint cannot be null.");
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
data = constraint.data;
bones = new Array(constraint.bones.size);
for (Bone bone : constraint.bones)
bones.add(skeleton.bones.get(bone.data.index));
target = skeleton.bones.get(constraint.target.data.index);
mix = constraint.mix;
bendDirection = constraint.bendDirection;
}
示例9: getStats
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[liquidinfo]Liquid Capacity: " + (int)liquidCapacity);
list.add("[liquidinfo]Power/Liquid: " + Strings.toFixed(powerPerLiquid, 2) + " power/liquid");
list.add("[liquidinfo]Max liquid/second: " + Strings.toFixed(maxLiquidGenerate*60f, 2) + " liquid/s");
list.add("[liquidinfo]Input: " + generateLiquid);
}
示例10: array
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
/**
* Transforms a group of Strings into an Array of Strings
* @param strings the strings to use
* @return the array
*/
public Array<String> array(String... strings) {
Array<String> ret = new Array<String>();
for (String s : strings) {
ret.add(s);
}
return ret;
}
示例11: fetchHighScores
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
private Array<Integer> fetchHighScores() {
Preferences prefs = Gdx.app.getPreferences("preferences");
Array<Integer> scores = new Array<Integer>();
for (int i = 0; i < 5; i++) {
scores.add(prefs.getInteger("score_" + i, 0));
}
return scores;
}
示例12: update
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
@Override
public void update(float delta) {
Level level = getLevel();
if(level == null) return;
Array<WorldObject> objects = new Array<>();
objects.addAll(level.getOverlappingEntities(getBounds(), this));
Tile tile = level.getClosestTile(getBounds());
if(tile != null) objects.add(tile);
for(WorldObject obj: objects)
obj.touching(this);
}
示例13: query
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
/**�߿ռ�����*/
public void query(Rectangle rect, Array<IQuadTreeObject> ret) {
// System.out.println("query side begin ---------- ");
// System.out.println("rect = " + rect + " type = " + type + "min, max, centerX, centerY = "
// + min + " " + max + " " + centerX + " " + centerY);
boolean flag = false;
switch(type) {
case 0:
if(rect.contains(min, centerY)) {
flag = true;
}
break;
case 1:
if(rect.contains(centerX, min)) {
flag = true;
}
break;
case 2:
if(rect.contains(max, centerY)) {
flag = true;
}
break;
case 3:
if(rect.contains(centerX, max)) {
flag = true;
}
break;
}
if(!flag) {return;}
// System.out.println("query side success ---------- ");
if(children != null) {
// System.out.println("query child side begin ---------- ");
children[0].query(rect, ret);
children[1].query(rect, ret);
// System.out.println("query child side end ---------- ");
}
for(int i = objs.size - 1; i >= 0; --i) {
ret.add(objs.get(i));
}
// System.out.println(this + " ret = " + objs.size);
}
示例14: createEnemy
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
private void createEnemy() {
mEnemyDaos = new Array<Enemy>();
Array<MapLayer> mapLayers = new Array<MapLayer>();
//天兵對象層
mapLayers.add(mMap.getLayers().get("enemy"));
mapLayers.add(mMap.getLayers().get("enemyFu"));
mapLayers.add(mMap.getLayers().get("enemyQiang"));
for (MapLayer mapLayer : mapLayers) {
if (mapLayer == null) {
continue;
}
//初始化天兵剛體形狀
BodyDef enemyDef = new BodyDef();
enemyDef.type = BodyDef.BodyType.DynamicBody;
//多邊形形狀
PolygonShape polygonShape = new PolygonShape();
//設置夾具
FixtureDef enemyFixDef = new FixtureDef();
//遍曆enemy對象層
for (MapObject object : mapLayer.getObjects()) {
//坐標
float x = 0;
float y = 0;
//獲取對象坐標
if (object instanceof EllipseMapObject) {
EllipseMapObject ellipseMapObject = (EllipseMapObject) object;
x = ellipseMapObject.getEllipse().x / Constant.RATE;
y = ellipseMapObject.getEllipse().y / Constant.RATE;
}
//天兵夾具
polygonShape.setAsBox(30 / Constant.RATE, 60 / Constant.RATE);
enemyFixDef.shape = polygonShape;
enemyFixDef.isSensor = true;
enemyFixDef.filter.categoryBits = Constant.ENEMY_DAO;
enemyFixDef.filter.maskBits = Constant.PLAYER;
//設置位置
enemyDef.position.set(x, y);
Body enemyBody = mWorld.createBody(enemyDef);
enemyBody.createFixture(enemyFixDef).setUserData("enemy");
//創建腳傳感器 foot
polygonShape.setAsBox(28 / Constant.RATE, 3 / Constant.RATE, new Vector2(0, -58 / Constant.RATE), 0);
enemyFixDef.shape = polygonShape;
enemyFixDef.filter.categoryBits = Constant.ENEMY_DAO;
enemyFixDef.filter.maskBits = Constant.BLOCK;
enemyFixDef.isSensor = false;
enemyBody.createFixture(enemyFixDef).setUserData("enemyFoot");
Enemy enemy = new Enemy(enemyBody, mapLayer.getName());
mEnemyDaos.add(enemy);
enemyBody.setUserData(enemy);
Thread thread = new Thread(enemy);
thread.start();
}
}
}
示例15: getStats
import com.badlogic.gdx.utils.Array; //導入方法依賴的package包/類
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[iteminfo]Capacity: " + capacity);
list.add("[iteminfo]Seconds/item: " + time);
}