本文整理汇总了Java中com.badlogic.ashley.benchmark.Constants.shouldHaveComponent方法的典型用法代码示例。如果您正苦于以下问题:Java Constants.shouldHaveComponent方法的具体用法?Java Constants.shouldHaveComponent怎么用?Java Constants.shouldHaveComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.ashley.benchmark.Constants
的用法示例。
在下文中一共展示了Constants.shouldHaveComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareWorld
import com.badlogic.ashley.benchmark.Constants; //导入方法依赖的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;
}
示例2: prepareEngine
import com.badlogic.ashley.benchmark.Constants; //导入方法依赖的package包/类
private static Engine prepareEngine (int numEntities) {
Engine engine = new Engine();
engine.addSystem(new MovementSystem());
engine.addSystem(new StateSystem());
engine.addSystem(new CollisionSystem());
engine.addSystem(new RemovalSystem());
for (int i = 0; i < numEntities; ++i) {
Entity entity = new Entity();
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.add(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.add(mov);
}
if (Constants.shouldHaveComponent(ComponentType.RADIUS, i)) {
RadiusComponent rad = new RadiusComponent();
rad.radius = MathUtils.random(Constants.MIN_RADIUS, Constants.MAX_RADIUS);
entity.add(rad);
}
if (Constants.shouldHaveComponent(ComponentType.STATE, i)) {
entity.add(new StateComponent());
}
engine.addEntity(entity);
}
return engine;
}
示例3: prepareWorld
import com.badlogic.ashley.benchmark.Constants; //导入方法依赖的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;
}
示例4: prepareEngine
import com.badlogic.ashley.benchmark.Constants; //导入方法依赖的package包/类
private static Engine prepareEngine(int numEntities) {
Engine engine = new Engine();
engine.addSystem(new MovementSystem());
engine.addSystem(new StateSystem());
engine.addSystem(new CollisionSystem());
engine.addSystem(new RemovalSystem());
for (int i = 0; i < numEntities; ++i) {
Entity entity = new Entity();
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.add(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.add(mov);
}
if (Constants.shouldHaveComponent(ComponentType.RADIUS, i)) {
RadiusComponent rad = new RadiusComponent();
rad.radius = MathUtils.random(Constants.MIN_RADIUS, Constants.MAX_RADIUS);
entity.add(rad);
}
if (Constants.shouldHaveComponent(ComponentType.STATE, i)) {
entity.add(new StateComponent());
}
engine.addEntity(entity);
}
return engine;
}