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


Java ComponentMapper类代码示例

本文整理汇总了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);
		}
	}
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:24,代码来源:IntervalIteratingTest.java

示例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);
}
 
开发者ID:DevelopersGuild,项目名称:rebel-invader,代码行数:23,代码来源:RenderingSystem.java

示例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;
	}
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:21,代码来源:StateSystem.java

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

示例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);
}
 
开发者ID:saltares,项目名称:ashley-superjumper,代码行数:22,代码来源:RenderingSystem.java

示例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;
		}
	});

}
 
开发者ID:e-ucm,项目名称:ead,代码行数:25,代码来源:DefaultGameView.java

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

示例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);
}
 
开发者ID:DevelopersGuild,项目名称:rebel-invader,代码行数:12,代码来源:PlayerSystem.java

示例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;
}
 
开发者ID:DevelopersGuild,项目名称:rebel-invader,代码行数:11,代码来源:BackgroundSystem.java

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

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

示例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);
}
 
开发者ID:DevelopersGuild,项目名称:rebel-invader,代码行数:12,代码来源:EnemySystem.java

示例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;
}
 
开发者ID:DevelopersGuild,项目名称:rebel-invader,代码行数:10,代码来源:PowerSystem.java

示例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);
}
 
开发者ID:DevelopersGuild,项目名称:rebel-invader,代码行数:11,代码来源:BulletSystem.java

示例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;
}
 
开发者ID:DevelopersGuild,项目名称:rebel-invader,代码行数:10,代码来源:HealthSystem.java


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