本文整理汇总了Java中com.artemis.Entity.addComponent方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.addComponent方法的具体用法?Java Entity.addComponent怎么用?Java Entity.addComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.artemis.Entity
的用法示例。
在下文中一共展示了Entity.addComponent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBoss
import com.artemis.Entity; //导入方法依赖的package包/类
public static Entity createBoss(int x, int y, int level) {
Entity boss = createMonster(x, y, level);
boss.addComponent(new Named("The Jailer"));
boss.addComponent(new Reward(Score.POINTS_KILL_JAILER));
boss.getComponent(Animation.class).id = "boss";
Color color = boss.getComponent(Animation.class).color;
Tox.world.getManager(TagManager.class).register(BOSS_TAG, boss);
return boss;
}
示例2: copyEntityFromOldWorld
import com.artemis.Entity; //导入方法依赖的package包/类
/**
* Copy entity from old world into the new one.
*
* This assumes the old world is no longer in use, and is potentially unsafe if it isn't. (The components are not cloned, just reused!)
*/
public static Entity copyEntityFromOldWorld( Entity old )
{
Entity entity = Tox.world.createEntity();
Bag<Component> fillBag = new Bag<Component>();
old.getComponents(fillBag);
for ( Component comp : fillBag )
{
entity.addComponent(comp);
}
return entity;
}
示例3: addMovingStarParticle
import com.artemis.Entity; //导入方法依赖的package包/类
public Entity addMovingStarParticle(int cx, int cy) {
Entity starParticle = addStarParticle(cx, cy);
Animation anim = starParticle.getComponent(Animation.class);
anim.layer = Animation.Layer.SCREEN_PARTICLE2;
anim.scale = MathUtils.random(0.25f,0.75f);
Physics physics = new Physics();
physics.velocityX = MathUtils.random(-50f,50f) * 5f;
physics.velocityY = MathUtils.random(25f,75f) * 5f;
physics.gravity = 9.8f * 0.5f;
starParticle.addComponent(physics);
return starParticle;
}
示例4: prepareWorld
import com.artemis.Entity; //导入方法依赖的package包/类
private static World prepareWorld (int numEntities) {
World world = new World();
world.setSystem(new MovementSystem());
world.setSystem(new StateSystem());
world.setSystem(new CollisionSystem());
world.setSystem(new RemovalSystem());
world.initialize();
for (int i = 0; i < numEntities; ++i) {
Entity entity = world.createEntity();
if (Constants.shouldHaveComponent(ComponentType.POSITION, i)) {
PositionComponent pos = new PositionComponent();
pos.pos.x = MathUtils.random(Constants.MIN_POS, Constants.MAX_POS);
pos.pos.y = MathUtils.random(Constants.MIN_POS, Constants.MAX_POS);
entity.addComponent(pos);
}
if (Constants.shouldHaveComponent(ComponentType.MOVEMENT, i)) {
MovementComponent mov = new MovementComponent();
mov.velocity.x = MathUtils.random(Constants.MIN_VEL, Constants.MAX_VEL);
mov.velocity.y = MathUtils.random(Constants.MIN_VEL, Constants.MAX_VEL);
mov.accel.x = MathUtils.random(Constants.MIN_ACC, Constants.MAX_ACC);
mov.accel.y = MathUtils.random(Constants.MIN_ACC, Constants.MAX_ACC);
entity.addComponent(mov);
}
if (Constants.shouldHaveComponent(ComponentType.RADIUS, i)) {
RadiusComponent rad = new RadiusComponent();
rad.radius = MathUtils.random(Constants.MIN_RADIUS, Constants.MAX_RADIUS);
entity.addComponent(rad);
}
if (Constants.shouldHaveComponent(ComponentType.STATE, i)) {
entity.addComponent(new StateComponent());
}
world.addEntity(entity);
}
return world;
}
示例5: createIndicator
import com.artemis.Entity; //导入方法依赖的package包/类
public static Entity createIndicator(int x, int y) {
Entity tile = createTile(x, y, "indicator", Animation.Layer.TILE_UNDER_COVER);
tile.addComponent(new ColorAnimation(Color.valueOf("f3d15e00"), Color.valueOf("f3d15eff"), Interpolation.fade, 0.5f, -1));
Tox.world.getManager(TagManager.class).register(INDICATOR_TAG, tile);
return tile;
}