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


Java World.createComponent方法代码示例

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


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

示例1: createBasicEntity

import com.artemis.World; //导入方法依赖的package包/类
private static Entity createBasicEntity(World world, float x, float y,
		int width, int height, float vx, float vy, float vmax, int health) {
	Entity e = world.createEntity();

	// Location data
	SpatialComp sc = world.createComponent(SpatialComp.class);
	sc.setValues(x, y, width, height);
	e.addComponent(sc);

	// Velocity data
	VelocityComp vc = world.createComponent(VelocityComp.class);
	vc.setValues(vx, vy, vmax);
	e.addComponent(vc);

	// Health data
	HealthComp hc = world.createComponent(HealthComp.class);
	hc.health = health;
	hc.killable = health != NO_HEALTH;
	e.addComponent(hc);

	return e;
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:23,代码来源:EntityFactory.java

示例2: addShipOffense

import com.artemis.World; //导入方法依赖的package包/类
private static Entity addShipOffense(World world, Entity e, int topL,
		int midL, int botL, int baseDmg, float fireRate) {
	// Level data
	LevelComp lc = world.createComponent(LevelComp.class);
	lc.setValues(topL, midL, botL);
	e.addComponent(lc);

	DamageComp dc = world.createComponent(DamageComp.class);
	// TODO better damage calculation??
	dc.damage = baseDmg;
	e.addComponent(dc);

	FireRateComp frc = world.createComponent(FireRateComp.class);
	frc.setValues(fireRate);
	e.addComponent(frc);

	return e;
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:19,代码来源:EntityFactory.java

示例3: createBoss

import com.artemis.World; //导入方法依赖的package包/类
public static void createBoss(World world, Level level) {
	Entity e = createBasicEntity(world,
			MathUtils.random(0, Gdx.graphics.getWidth() - 144),
			Gdx.graphics.getHeight() - 108, 144, 108, 0, 0, 0,
			Constants.Enemy.BASE_HEALTH);
	addShipOffense(world, e, 0, 0, 1, Constants.Enemy.BASE_DAMAGE,
			Constants.Enemy.FIRE_RATE);

	SingleSpriteComp ssc = world.createComponent(SingleSpriteComp.class);
	ssc.name = "Boss1_V2";
	ssc.tint = level.tint;
	e.addComponent(ssc);

	e.addComponent(world.createComponent(NonCullComp.class));

	world.getManager(GroupManager.class).add(e, Constants.Groups.ENEMY);
	e.addToWorld();
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:19,代码来源:EntityFactory.java

示例4: createShot

import com.artemis.World; //导入方法依赖的package包/类
public static void createShot(World world, float x, float y, int damage,
		Color tint, boolean playerShot) {
	Entity e = createBasicEntity(world, x, y, Constants.Shot.WIDTH,
			Constants.Shot.HEIGHT, 0, Constants.Shot.VEL
					* ((playerShot) ? 1 : -1), 0, NO_HEALTH);

	SingleSpriteComp ssc = world.createComponent(SingleSpriteComp.class);
	ssc.name = Constants.Shot.SHOT_NAME;
	ssc.tint = tint;
	e.addComponent(ssc);

	DamageComp dc = world.createComponent(DamageComp.class);
	dc.damage = damage;
	e.addComponent(dc);

	world.getManager(GroupManager.class).add(
			e,
			playerShot ? Constants.Groups.PLAYER_ATTACK
					: Constants.Groups.ENEMY_ATTACK);
	e.addToWorld();
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:22,代码来源:EntityFactory.java

示例5: createMissile

import com.artemis.World; //导入方法依赖的package包/类
private static void createMissile(World world, float sourceX,
		float sourceY, Entity target) {
	Entity e = createBasicEntity(world, sourceX + Constants.SHIP_WIDTH / 2
			- Constants.Missile.WIDTH / 2, sourceY + Constants.SHIP_HEIGHT,
			Constants.Missile.WIDTH, Constants.Missile.HEIGHT, 0, 0,
			Constants.Missile.VEL, NO_HEALTH);

	DamageComp dc = world.createComponent(DamageComp.class);
	dc.damage = Integer.MAX_VALUE; // Max Value so it's an insta-kill
	e.addComponent(dc);

	TargetComp tc = world.createComponent(TargetComp.class);
	tc.target = target;
	tc.targetGroup = Constants.Groups.ENEMY;
	e.addComponent(tc);

	SingleSpriteComp ssc = world.createComponent(SingleSpriteComp.class);
	ssc.name = Constants.Missile.NAME;
	ssc.tint = Color.WHITE;
	e.addComponent(ssc);

	world.getManager(GroupManager.class).add(e,
			Constants.Groups.PLAYER_ATTACK);
	e.addToWorld();
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:26,代码来源:EntityFactory.java

示例6: createExplosion

import com.artemis.World; //导入方法依赖的package包/类
public static void createExplosion(World world, float x, float y,
		float xVel, float yVel) {
	Entity e = createBasicEntity(world, x, y, Constants.Explosion.WIDTH,
			Constants.Explosion.HEIGHT,
			xVel * Constants.Explosion.VEL_PERC, yVel
					* Constants.Explosion.VEL_PERC, 0, NO_HEALTH);

	SingleSpriteComp ssc = world.createComponent(SingleSpriteComp.class);
	ssc.name = Constants.Explosion.NAME;
	ssc.tint = Color.WHITE;
	e.addComponent(ssc);

	TimeDelComp tdc = world.createComponent(TimeDelComp.class);
	tdc.setValues(Constants.Explosion.LIFE_TIME);
	e.addComponent(tdc);

	e.addToWorld();
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:19,代码来源:EntityFactory.java

示例7: createEnemy

import com.artemis.World; //导入方法依赖的package包/类
public static void createEnemy(World world) {
	Entity e = createBasicEntity(
			world,
			MathUtils.random(0, Gdx.graphics.getWidth()
					- Constants.SHIP_WIDTH), Gdx.graphics.getHeight(),
			Constants.SHIP_WIDTH, Constants.SHIP_HEIGHT, 0,
			-Constants.Enemy.MAX_MOVE, Constants.Enemy.MAX_MOVE,
			Constants.Enemy.BASE_HEALTH);
	addShipOffense(world, e, 0, 0, 1, Constants.Enemy.BASE_DAMAGE,
			Constants.Enemy.FIRE_RATE);

	SingleSpriteComp ssc = world.createComponent(SingleSpriteComp.class);
	ssc.name = Constants.Enemy.NAMES[MathUtils
			.random(Constants.Enemy.NAMES.length - 1)];
	ssc.tint = Color.GRAY;
	e.addComponent(ssc);

	// Path following ai
	PathFollowComp pfc = world.createComponent(PathFollowComp.class);
	pfc.setValues(PathFactory.createPath());
	e.addComponent(pfc);

	PathTargetComp tc = world.createComponent(PathTargetComp.class);
	tc.target = pfc.path.get(pfc.target);
	e.addComponent(tc);

	// Enemies are deleted when they get to the end of the path
	e.addComponent(world.createComponent(NonCullComp.class));

	world.getManager(GroupManager.class).add(e, Constants.Groups.ENEMY);
	e.addToWorld();
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:33,代码来源:EntityFactory.java

示例8: createBubble

import com.artemis.World; //导入方法依赖的package包/类
private static Entity createBubble(World world, float sourceX,
		float sourceY, int bubWidth, int bubHeight, String imgName,
		int health) {
	Entity e = world.createEntity();

	MoveWithPlayerComp mwpc = world
			.createComponent(MoveWithPlayerComp.class);
	mwpc.xDisplace = -(bubWidth - Constants.SHIP_WIDTH) / 2;
	mwpc.yDispace = -(bubHeight - Constants.SHIP_HEIGHT) / 2;
	e.addComponent(mwpc);

	SpatialComp sc = world.createComponent(SpatialComp.class);
	sc.setValues(sourceX + mwpc.xDisplace, sourceY + mwpc.yDispace,
			bubWidth, bubHeight);
	e.addComponent(sc);

	SingleSpriteComp ssc = world.createComponent(SingleSpriteComp.class);
	ssc.name = imgName;
	ssc.tint = Color.WHITE;
	e.addComponent(ssc);

	HealthComp hc = world.createComponent(HealthComp.class);
	hc.health = health;
	e.addComponent(hc);

	e.addComponent(world.createComponent(NonCullComp.class));
	world.getManager(GroupManager.class).add(e, Constants.Groups.PLAYER);
	return e;
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:30,代码来源:EntityFactory.java

示例9: createInvincibility

import com.artemis.World; //导入方法依赖的package包/类
private static void createInvincibility(World world, float sourceX,
		float sourceY) {
	Entity e = createBubble(world, sourceX, sourceY,
			Constants.Invincibility.WIDTH, Constants.Invincibility.HEIGHT,
			Constants.Invincibility.NAME, Constants.Invincibility.HEALTH);

	TimeDelComp tdc = world.createComponent(TimeDelComp.class);
	tdc.setValues(Constants.Invincibility.TIME_OUT);
	e.addComponent(tdc);

	e.addToWorld();
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:13,代码来源:EntityFactory.java

示例10: makeChild

import com.artemis.World; //导入方法依赖的package包/类
public static void makeChild(World world, Entity parent, Entity child) {
	ChildLinked childLink = world.createComponent(ChildLinked.class);
	childLink.parentEntity = parent;

	child.addComponent(childLink);
}
 
开发者ID:UoLCompSoc,项目名称:mobius,代码行数:7,代码来源:ChildLinked.java

示例11: createPlayer

import com.artemis.World; //导入方法依赖的package包/类
/**
 * Creates the player, returning so other classes can have easy access to it
 * 
 * @param world
 * @return
 */
public static Entity createPlayer(World world) {
	Entity e = createBasicEntity(world, Gdx.graphics.getWidth() / 2
			- Constants.SHIP_WIDTH / 2, Constants.Player.MIN_Y,
			Constants.SHIP_WIDTH, Constants.SHIP_HEIGHT,
			Constants.Player.START_VEL, Constants.Player.START_VEL,
			Constants.Player.MAX_MOVE, Constants.Player.BASE_HEALTH);

	addShipOffense(world, e, Constants.Player.BASE_PART_LVL,
			Constants.Player.BASE_PART_LVL, Constants.Player.BASE_PART_LVL,
			Constants.Player.BASE_DAMAGE, Constants.Player.FIRE_RATE);

	// Distinguishing comp
	e.addComponent(world.createComponent(PlayerComp.class));

	// Drawing
	ShipSpritesComp ssc = world.createComponent(ShipSpritesComp.class);
	ssc.setValues(Constants.Player.ARTEMIS_TOP,
			Constants.Player.ARTEMIS_MID, Constants.Player.ARTEMIS_BOT);
	e.addComponent(ssc);

	ShipColorsComp scc = world.createComponent(ShipColorsComp.class);
	scc.setValues(Color.GREEN, Color.RED, Color.BLUE);
	e.addComponent(scc);

	// Testing values
	SpecialComp spc = world.createComponent(SpecialComp.class);
	spc.defensive = DefensiveSpecialType.INVINCIBLITY;
	spc.defensiveCount = Integer.MAX_VALUE;

	spc.offensive = OffensiveSpecialType.BEAM;
	spc.offensiveCount = Integer.MAX_VALUE;
	e.addComponent(spc);

	// Deletion is handled separately
	e.addComponent(world.createComponent(NonCullComp.class));

	world.getManager(GroupManager.class).add(e, Constants.Groups.PLAYER);
	e.addToWorld();
	return e;
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:47,代码来源:EntityFactory.java

示例12: createBeam

import com.artemis.World; //导入方法依赖的package包/类
private static void createBeam(World world, float srcX, float srcY) {
	// Beams are actually just a bunch of beams
	int numBeams = Gdx.graphics.getHeight() / Constants.Beam.HEIGHT + 1;
	float y = srcY + Constants.SHIP_HEIGHT;
	float x = srcX + Constants.SHIP_WIDTH / 2 - Constants.Beam.WIDTH / 2;
	GroupManager gm = world.getManager(GroupManager.class);
	for (int i = 0; i < numBeams; ++i) {
		Entity e = world.createEntity();
		gm.removeFromAllGroups(e);

		MoveWithPlayerComp mwpc = world
				.createComponent(MoveWithPlayerComp.class);
		mwpc.xDisplace = Constants.SHIP_WIDTH / 2 - Constants.Beam.WIDTH
				/ 2;
		mwpc.yDispace = Constants.SHIP_HEIGHT + Constants.Beam.HEIGHT * i;
		e.addComponent(mwpc);

		SpatialComp sc = world.createComponent(SpatialComp.class);
		sc.setValues(x, y, Constants.Beam.WIDTH, Constants.Beam.HEIGHT);
		e.addComponent(sc);

		SingleSpriteComp ssc = world
				.createComponent(SingleSpriteComp.class);
		ssc.name = Constants.Beam.NAME;
		ssc.tint = Color.WHITE;
		e.addComponent(ssc);

		DamageComp dc = world.createComponent(DamageComp.class);
		dc.damage = Constants.Beam.BASE_DAMAGE;
		e.addComponent(dc);

		HealthComp hc = world.createComponent(HealthComp.class);
		hc.health = Constants.Beam.HEALTH;
		hc.killable = false;
		e.addComponent(hc);

		// Beams are removed after a certain amount of time, so don't cull
		// them
		e.addComponent(world.createComponent(NonCullComp.class));

		TimeDelComp tdc = world.createComponent(TimeDelComp.class);
		tdc.setValues(Constants.Beam.TIME_OUT);
		e.addComponent(tdc);

		gm.add(e, Constants.Groups.PLAYER_ATTACK);
		e.addToWorld();

		y += Constants.Beam.HEIGHT;
	}
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:51,代码来源:EntityFactory.java

示例13: makePositionOpacityLink

import com.artemis.World; //导入方法依赖的package包/类
/**
 * <p>
 * Creates a new {@link PositionOpacityLinkPerformer} between the parent and
 * child entities.
 * </p>
 * 
 * @param world
 *        The world in which the entities reside.
 * @param parent
 *        The parent entity.
 * @param child
 *        The child entity; see {@link PositionOpacityLinkPerformer} for
 *        changes which performer.perform(parent) will carry out.
 * @param xOffset
 *        How far in the x direction the child should be offset.
 * @param yFlip
 *        The way to "flip" the position of the child entity when mirrored.
 */
public static void makePositionOpacityLink(World world, Entity parent, Entity child, float xOffset, float yFlip) {
	Linked link = world.createComponent(Linked.class);
	link.child = child;
	link.performer = link.new PositionOpacityLinkPerformer(world, xOffset, yFlip);

	parent.addComponent(link);
}
 
开发者ID:UoLCompSoc,项目名称:mobius,代码行数:26,代码来源:Linked.java


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