本文整理汇总了Java中com.badlogic.ashley.core.ComponentMapper类的典型用法代码示例。如果您正苦于以下问题:Java ComponentMapper类的具体用法?Java ComponentMapper怎么用?Java ComponentMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComponentMapper类属于com.badlogic.ashley.core包,在下文中一共展示了ComponentMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intervalSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
@Test
public void intervalSystem () {
Engine engine = new Engine();
IntervalIteratingSystemSpy intervalSystemSpy = new IntervalIteratingSystemSpy();
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(IntervalComponentSpy.class).get());
ComponentMapper<IntervalComponentSpy> im = ComponentMapper.getFor(IntervalComponentSpy.class);
engine.addSystem(intervalSystemSpy);
for (int i = 0; i < 10; ++i) {
Entity entity = new Entity();
entity.add(new IntervalComponentSpy());
engine.addEntity(entity);
}
for (int i = 1; i <= 10; ++i) {
engine.update(deltaTime);
for (int j = 0; j < entities.size(); ++j) {
assertEquals(i / 2, im.get(entities.get(j)).numUpdates);
}
}
}
示例2: RenderingSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public RenderingSystem(SpriteBatch batch) {
super(Family.all(TransformComponent.class, TextureComponent.class).get());
textureM = ComponentMapper.getFor(TextureComponent.class);
transformM = ComponentMapper.getFor(TransformComponent.class);
renderQueue = new Array<Entity>();
comparator = new Comparator<Entity>() {
@Override
public int compare(Entity entityA, Entity entityB) {
return (int) Math.signum(transformM.get(entityB).pos.z -
transformM.get(entityA).pos.z);
}
};
this.batch = batch;
cam = new OrthographicCamera(FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
cam.position.set(FRUSTUM_WIDTH / 2, FRUSTUM_HEIGHT / 2, 0);
}
示例3: processEntity
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
@Override
protected void processEntity(Entity entity, float deltaTime) // State logic
{
// Check if runnable must be executed
for(ComponentMapper<StateComponent> mapper : stateMappers)
{
StateComponent state = (StateComponent) mapper.get(entity);
if(state == null)
continue;
if(state.runnable != null && state.secondsToRunRunnable <= state.secondsInState && !state.runnableWasExecuted)
{
state.runnableWasExecuted = true;
state.runnable.run();
}
state.secondsInState += deltaTime;
}
}
示例4: intervalSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
@Test
public void intervalSystem() {
Engine engine = new Engine();
IntervalIteratingSystemSpy intervalSystemSpy = new IntervalIteratingSystemSpy();
ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.getFor(IntervalComponentSpy.class));
ComponentMapper<IntervalComponentSpy> im = ComponentMapper.getFor(IntervalComponentSpy.class);
engine.addSystem(intervalSystemSpy);
for (int i = 0; i < 10; ++i) {
Entity entity = new Entity();
entity.add(new IntervalComponentSpy());
engine.addEntity(entity);
}
for (int i = 1; i <= 10; ++i) {
engine.update(deltaTime);
for (int j = 0; j < entities.size(); ++j) {
assertEquals(i / 2, im.get(entities.get(j)).numUpdates);
}
}
}
示例5: RenderingSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public RenderingSystem(SpriteBatch batch) {
super(Family.all(TransformComponent.class, TextureComponent.class).get());
textureM = ComponentMapper.getFor(TextureComponent.class);
transformM = ComponentMapper.getFor(TransformComponent.class);
renderQueue = new Array<Entity>();
comparator = new Comparator<Entity>() {
@Override
public int compare(Entity entityA, Entity entityB) {
return (int)Math.signum(transformM.get(entityB).pos.z -
transformM.get(entityA).pos.z);
}
};
this.batch = batch;
cam = new OrthographicCamera(FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
cam.position.set(FRUSTUM_WIDTH / 2, FRUSTUM_HEIGHT / 2, 0);
}
示例6: initKeyboardListener
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
private void initKeyboardListener() {
addListener(new InputListener() {
final ComponentMapper<KeyPressedComponent> keyPressed = ComponentMapper
.getFor(KeyPressedComponent.class);
public boolean keyDown(InputEvent event, int keycode) {
EngineEntity entity = getLayer(Layer.SCENE);
if (!keyPressed.has(entity)) {
entity.add(gameLoop
.createComponent(KeyPressedComponent.class));
}
KeyPressedComponent keyPressedComponent = entity
.getComponent(KeyPressedComponent.class);
RuntimeKey runtimeKeyEvent = Pools.obtain(RuntimeKey.class);
runtimeKeyEvent.setKeycode(keycode);
runtimeKeyEvent.setAlt(UIUtils.alt());
runtimeKeyEvent.setCtrl(UIUtils.ctrl());
runtimeKeyEvent.setShift(UIUtils.shift());
keyPressedComponent.getKeyEvents().add(runtimeKeyEvent);
return true;
}
});
}
示例7: RenderSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public RenderSystem(Camera camera, int tileWidth) {
super(Family.all(SpriteComponent.class, TransformComponent.class).get());
this.tileWidth = tileWidth / 2f;
this.camera = camera;
batch = new SpriteBatch();
spriteM = ComponentMapper.getFor(SpriteComponent.class);
positionM = ComponentMapper.getFor(TransformComponent.class);
}
示例8: PlayerSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public PlayerSystem(Level level) {
super(family);
this.level = level;
rm = ComponentMapper.getFor(PlayerComponent.class);
sm = ComponentMapper.getFor(StateComponent.class);
tm = ComponentMapper.getFor(TransformComponent.class);
mm = ComponentMapper.getFor(MovementComponent.class);
bm = ComponentMapper.getFor(BodyComponent.class);
texm = ComponentMapper.getFor(TextureComponent.class);
}
示例9: BackgroundSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public BackgroundSystem() {
super(Family.all(BackgroundComponent.class).get());
bm = ComponentMapper.getFor(BackgroundComponent.class);
txm = ComponentMapper.getFor(TextureComponent.class);
tm = ComponentMapper.getFor(TransformComponent.class);
nebulaStep = 0f;
starsStep = 0f;
}
示例10: ExplosionSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public ExplosionSystem(GameScreen screen) {
super(family);
this.screen = screen;
ComponentMapper.getFor(TransformComponent.class);
em = ComponentMapper.getFor(ExplosionComponent.class);
bm = ComponentMapper.getFor(BodyComponent.class);
}
示例11: HeightDisposableSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public HeightDisposableSystem(GameScreen screen) {
super(Family.all(StructureComponent.class).get());
tm = ComponentMapper.getFor(TransformComponent.class);
hm = ComponentMapper.getFor(HeightDisposableComponent.class);
this.screen = screen;
}
示例12: EnemySystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public EnemySystem(Level level) {
super(family);
currentTime = 0f;
this.level = level;
em = ComponentMapper.getFor(EnemyComponent.class);
tm = ComponentMapper.getFor(TransformComponent.class);
mm = ComponentMapper.getFor(MovementComponent.class);
bm = ComponentMapper.getFor(BodyComponent.class);
sm = ComponentMapper.getFor(StateComponent.class);
}
示例13: PowerSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public PowerSystem(GameScreen screen) {
super(family);
this.screen = screen;
tm = ComponentMapper.getFor(TransformComponent.class);
pm = ComponentMapper.getFor(PowerComponent.class);
powerLastFrame = 0f;
}
示例14: BulletSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public BulletSystem(GameScreen screen) {
super(family);
this.screen = screen;
bm = ComponentMapper.getFor(BodyComponent.class);
blm = ComponentMapper.getFor(BulletComponent.class);
mm = ComponentMapper.getFor(MovementComponent.class);
//sm = ComponentMapper.getFor(StateComponent.class);
//tm = ComponentMapper.getFor(TransformComponent.class);
}
示例15: HealthSystem
import com.badlogic.ashley.core.ComponentMapper; //导入依赖的package包/类
public HealthSystem(GameScreen screen) {
super(family);
this.screen = screen;
tm = ComponentMapper.getFor(TransformComponent.class);
hm = ComponentMapper.getFor(HealthComponent.class);
healthLastFrame = 0f;
}