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


Java Array.add方法代码示例

本文整理汇总了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;
    }
 
开发者ID:ZephyrVentum,项目名称:FlappySpinner,代码行数:20,代码来源:WorldUtils.java

示例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;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:25,代码来源:GpgsClient.java

示例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;
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:25,代码来源:KyperMapLoader.java

示例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;
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:18,代码来源:AnimationFactory.java

示例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);
}
 
开发者ID:ZKasica,项目名称:Planet-Generator,代码行数:25,代码来源:Trajectory.java

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

示例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;
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:9,代码来源:PieceHolder.java

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

示例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);
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:9,代码来源:LiquidPowerGenerator.java

示例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;
}
 
开发者ID:Benjozork,项目名称:Onyx,代码行数:13,代码来源:Utils.java

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

示例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);
}
 
开发者ID:chrisj42,项目名称:miniventure,代码行数:13,代码来源:Entity.java

示例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);
		}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:45,代码来源:QuadTreeV2.java

示例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();
		}
	}
}
 
开发者ID:heyzqt,项目名称:libGdx-xiyou,代码行数:64,代码来源:Play.java

示例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);
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:7,代码来源:Drill.java


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