本文整理汇总了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);
}