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


Java Engine.addSystem方法代码示例

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


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

示例1: intervalSystem

import com.badlogic.ashley.core.Engine; //导入方法依赖的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: create

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
@Override
public void create()
{
	GameSettingsComponent settings = new GameSettingsComponent();
	settings.setGuiWidth(width);
	settings.setGuiHeight(height);
	settings.setWorldToScreen(32f);
	settings.setGravity(new Vector2(0, -9.81f));
	settings.setTimeStep(1 / 300f);
	settings.setPaused(false);

	GameWorld gameWorld = new GameWorld(settings);

	engine = new Engine();
	engine.addEntity(gameWorld);

	engine.addSystem(new AccumulatorSystem());
	engine.addSystem(new MovementSystem());
	engine.addSystem(new JumpingSystem());

	setScreen(new GameScreen(engine, gameWorld.getId()));
}
 
开发者ID:kLeZ,项目名称:LibGDX-MVC-Tutorial,代码行数:23,代码来源:MvcGame.java

示例3: intervalSystem

import com.badlogic.ashley.core.Engine; //导入方法依赖的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

示例4: create

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
@Override
public void create() {
	Gdx.input.setInputProcessor(inputProcessor);

	physicsWorld = new World(new Vector2(0, -30), true);

	entityEngine = new Engine();
	entityEngine.addEntity(new CharacterEntity(physicsWorld));
	entityEngine.addSystem(new PhysicsSystem(physicsWorld));
	entityEngine.addSystem(new InputSystem(inputProcessor));

	SceneRenderer sceneRenderer = new SceneRenderer(physicsWorld);
	renderer = new PixelatedRenderer(sceneRenderer);

	Level level = Level.fromMapPath("levels/level0.tmx");
	level.populatePhysicsWorld(physicsWorld);
}
 
开发者ID:sftrabbit,项目名称:Interplanar,代码行数:18,代码来源:Interplanar.java

示例5: add

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
/**
 * Adds all required systems to the engine
 * 
 * @param engine
 */
public static void add(Application app, Engine engine) {

	//engine.addSystem(new TweakingSystem());
	engine.addSystem(new FlockingSystem());
	engine.addSystem(new CameraSystem());
	engine.addSystem(new RenderSystem(app.getPhysicalSurface()));
	engine.addSystem(new MusicSystem());
	engine.addSystem(new PathFollowSystem());

	
}
 
开发者ID:urstruktur,项目名称:zierfisch,代码行数:17,代码来源:Systems.java

示例6: shouldIterateEntitiesWithCorrectFamily

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void shouldIterateEntitiesWithCorrectFamily () {
	final Engine engine = new Engine();

	final Family family = Family.all(ComponentA.class, ComponentB.class).get();
	final IteratingSystemMock system = new IteratingSystemMock(family);
	final Entity e = new Entity();

	engine.addSystem(system);
	engine.addEntity(e);

	// When entity has ComponentA
	e.add(new ComponentA());
	engine.update(deltaTime);

	assertEquals(0, system.numUpdates);

	// When entity has ComponentA and ComponentB
	system.numUpdates = 0;
	e.add(new ComponentB());
	engine.update(deltaTime);

	assertEquals(1, system.numUpdates);

	// When entity has ComponentA, ComponentB and ComponentC
	system.numUpdates = 0;
	e.add(new ComponentC());
	engine.update(deltaTime);

	assertEquals(1, system.numUpdates);

	// When entity has ComponentB and ComponentC
	system.numUpdates = 0;
	e.remove(ComponentA.class);
	e.add(new ComponentC());
	engine.update(deltaTime);

	assertEquals(0, system.numUpdates);
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:41,代码来源:IteratingSystemTest.java

示例7: shouldIterateEntitiesWithCorrectFamily

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void shouldIterateEntitiesWithCorrectFamily () {
	final Engine engine = new Engine();

	final Family family = Family.all(OrderComponent.class, ComponentB.class).get();
	final SortedIteratingSystemMock system = new SortedIteratingSystemMock(family);
	final Entity e = new Entity();

	engine.addSystem(system);
	engine.addEntity(e);

	// When entity has OrderComponent
	e.add(new OrderComponent("A", 0));
	engine.update(deltaTime);

	// When entity has OrderComponent and ComponentB
	e.add(new ComponentB());
	system.expectedNames.addLast("A");
	engine.update(deltaTime);

	// When entity has OrderComponent, ComponentB and ComponentC
	e.add(new ComponentC());
	system.expectedNames.addLast("A");
	engine.update(deltaTime);

	// When entity has ComponentB and ComponentC
	e.remove(OrderComponent.class);
	e.add(new ComponentC());
	engine.update(deltaTime);
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:32,代码来源:SortedIteratingSystemTest.java

示例8: entityOrder

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
@Test
public void entityOrder () {
	Engine engine = new Engine();

	final Family family = Family.all(OrderComponent.class).get();
	final SortedIteratingSystemMock system = new SortedIteratingSystemMock(family);
	engine.addSystem(system);

	Entity a = createOrderEntity("A", 0);
	Entity b = createOrderEntity("B", 1);
	Entity c = createOrderEntity("C", 3);
	Entity d = createOrderEntity("D", 2);

	engine.addEntity(a);
	engine.addEntity(b);
	engine.addEntity(c);
	system.expectedNames.addLast("A");
	system.expectedNames.addLast("B");
	system.expectedNames.addLast("C");
	engine.update(0);

	engine.addEntity(d);
	system.expectedNames.addLast("A");
	system.expectedNames.addLast("B");
	system.expectedNames.addLast("D");
	system.expectedNames.addLast("C");
	engine.update(0);

	orderMapper.get(a).zLayer = 3;
	orderMapper.get(b).zLayer = 2;
	orderMapper.get(c).zLayer = 1;
	orderMapper.get(d).zLayer = 0;
	system.forceSort();
	system.expectedNames.addLast("D");
	system.expectedNames.addLast("C");
	system.expectedNames.addLast("B");
	system.expectedNames.addLast("A");
	engine.update(0);
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:40,代码来源:SortedIteratingSystemTest.java

示例9: intervalSystem

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
@Test
public void intervalSystem () {
	Engine engine = new Engine();
	IntervalSystemSpy intervalSystemSpy = new IntervalSystemSpy();

	engine.addSystem(intervalSystemSpy);

	for (int i = 1; i <= 10; ++i) {
		engine.update(deltaTime);
		assertEquals(i / 2, intervalSystemSpy.numUpdates);
	}
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:13,代码来源:IntervalSystemTest.java

示例10: main

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
public static void main (String[] args) {
	Engine engine = new Engine();

	engine.addSystem(new SystemA(10));
	engine.addSystem(new SystemB(5));
	engine.addSystem(new SystemA(2));

	engine.update(0);
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:10,代码来源:SystemPriorityTest.java

示例11: Systems

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
public Systems(Engine engine){

		engine.addSystem(physics);
		engine.addSystem(agent);
		engine.addSystem(camera);
		engine.addSystem(move);
		engine.addSystem(player);
		engine.addSystem(weapon);
		engine.addSystem(lifetime);
		engine.addSystem(vision);
		//engine.addSystem(rangedGroundAI);
		//engine.addSystem(civilianGroundAI);
		engine.addSystem(spriteRender);
		engine.addSystem(team);
		engine.addSystem(collectable);
		engine.addSystem(spawn);
		engine.addSystem(damage);
		engine.addSystem(particle);
		//engine.addSystem(helicopterAI);
		engine.addSystem(vehicle);
		
		engine.addEntityListener(camera);
		engine.addEntityListener(physics);
		engine.addEntityListener(player);
		engine.addEntityListener(spriteRender);

	}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:28,代码来源:Systems.java

示例12: init

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
@Setup
public void init() {
	engine = new Engine();
	engine.addSystem(new PlainPositionSystem());
	engine.addSystem(new PlainPositionSystem2());
	engine.addSystem(new PlainPositionSystem3());
	engine.addSystem(new EntityDeleterSystem(JmhSettings.SEED, entityCount, PlainPosition.class, PlainStructComponentA.class));
}
 
开发者ID:junkdog,项目名称:entity-system-benchmarks,代码行数:9,代码来源:PlainComponentBenchmark.java

示例13: init

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
@Setup
public void init() {
	engine = new Engine();
	engine.addSystem(new EntityDeleterSystem(SEED, entityCount, PlainPosition.class, PlainStructComponentA.class));
	engine.addSystem(new BaselinePositionSystem());
	engine.addSystem(new BaselinePositionSystem2());
	engine.addSystem(new BaselinePositionSystem3());
}
 
开发者ID:junkdog,项目名称:entity-system-benchmarks,代码行数:9,代码来源:BaselineBenchmark.java

示例14: init

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
@Setup
public void init() throws Exception {
	engine = new Engine();
	engine.addSystem(new EntityManglerSystem(SEED, entityCount));
	engine.addSystem(new CompSystemA());
	engine.addSystem(new CompSystemB());
	engine.addSystem(new CompSystemC());
	engine.addSystem(new CompSystemD());
}
 
开发者ID:junkdog,项目名称:entity-system-benchmarks,代码行数:10,代码来源:InsertRemoveBenchmark.java

示例15: shouldIterateEntitiesWithCorrectFamily

import com.badlogic.ashley.core.Engine; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void shouldIterateEntitiesWithCorrectFamily() {
    final Engine engine = new Engine();

    final Family family = Family.getFor(ComponentA.class, ComponentB.class);
    final IteratingSystemMock system = new IteratingSystemMock(family);
    final Entity e = new Entity();

    engine.addSystem(system);
    engine.addEntity(e);

    //When entity has ComponentA
    e.add(new ComponentA());
    engine.update(deltaTime);

    assertEquals(0, system.numUpdates);

    //When entity has ComponentA and ComponentB
    system.numUpdates = 0;
    e.add(new ComponentB());
    engine.update(deltaTime);

    assertEquals(1, system.numUpdates);

    //When entity has ComponentA, ComponentB and ComponentC
    system.numUpdates = 0;
    e.add(new ComponentC());
    engine.update(deltaTime);

    assertEquals(1, system.numUpdates);

    //When entity has ComponentB and ComponentC
    system.numUpdates = 0;
    e.remove(ComponentA.class);
    e.add(new ComponentC());
    engine.update(deltaTime);

    assertEquals(0, system.numUpdates);
}
 
开发者ID:grum,项目名称:Ashley,代码行数:41,代码来源:IteratingSystemTest.java


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