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


Java PooledEngine.addSystem方法代码示例

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


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

示例1: setupEngine

import com.badlogic.ashley.core.PooledEngine; //导入方法依赖的package包/类
protected void setupEngine(PooledEngine engine, SpriteBatch batch) {
    RenderSystem renderSystem = new RenderSystem(batch);
    engine.addSystem(renderSystem);
    engine.addSystem(new BoundarySystem(Asteroids.VIRTUAL_WIDTH, Asteroids.VIRTUAL_HEIGHT));
    engine.addSystem(new AnimationSystem());
    engine.addSystem(new AchievementSystem());
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:8,代码来源:BaseGamePresenter.java

示例2: main

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

	MovementSystem movementSystem = new MovementSystem();
	PositionSystem positionSystem = new PositionSystem();

	engine.addSystem(movementSystem);
	engine.addSystem(positionSystem);

	Listener listener = new Listener();
	engine.addEntityListener(listener);

	for (int i = 0; i < 10; i++) {
		Entity entity = engine.createEntity();
		entity.add(new PositionComponent(10, 0));
		if (i > 5) entity.add(new MovementComponent(10, 2));

		engine.addEntity(entity);
	}

	log("MovementSystem has: " + movementSystem.entities.size() + " entities.");
	log("PositionSystem has: " + positionSystem.entities.size() + " entities.");

	for (int i = 0; i < 10; i++) {
		engine.update(0.25f);

		if (i > 5) engine.removeSystem(movementSystem);
	}

	engine.removeEntityListener(listener);
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:32,代码来源:BasicTest.java

示例3: create

import com.badlogic.ashley.core.PooledEngine; //导入方法依赖的package包/类
@Override
public void create () {
	OrthographicCamera camera = new OrthographicCamera(640, 480);
	camera.position.set(320, 240, 0);
	camera.update();

	Texture crateTexture = new Texture("assets/crate.png");
	Texture coinTexture = new Texture("assets/coin.png");

	engine = new PooledEngine();
	engine.addSystem(new RenderSystem(camera));
	engine.addSystem(new MovementSystem());

	Entity crate = engine.createEntity();
	crate.add(new PositionComponent(50, 50));
	crate.add(new VisualComponent(new TextureRegion(crateTexture)));

	engine.addEntity(crate);

	TextureRegion coinRegion = new TextureRegion(coinTexture);

	for (int i = 0; i < 100; i++) {
		Entity coin = engine.createEntity();
		coin.add(new PositionComponent(MathUtils.random(640), MathUtils.random(480)));
		coin.add(new MovementComponent(10.0f, 10.0f));
		coin.add(new VisualComponent(coinRegion));
		engine.addEntity(coin);
	}
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:30,代码来源:RenderSystemTest.java

示例4: main

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

	CounterSystem counter = new CounterSystem();
	IgnoredSystem ignored = new IgnoredSystem();

	engine.addSystem(counter);
	engine.addSystem(ignored);

	for (int i = 0; i < 10; i++) {
		engine.update(0.25f);
	}
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:14,代码来源:IgnoreSystemTest.java

示例5: init

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

示例6: main

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

    MovementSystem movementSystem = new MovementSystem();
    PositionSystem positionSystem = new PositionSystem();

    engine.addSystem(movementSystem);
    engine.addSystem(positionSystem);

    Listener listener = new Listener();
    engine.addEntityListener(listener);

    for (int i = 0; i < 10; i++) {
        Entity entity = engine.createEntity();
        entity.add(new PositionComponent(10, 0));
        if (i > 5) {
            entity.add(new MovementComponent(10, 2));
        }

        engine.addEntity(entity);
    }

    log("MovementSystem has: " + movementSystem.entities.size() + " entities.");
    log("PositionSystem has: " + positionSystem.entities.size() + " entities.");

    for (int i = 0; i < 10; i++) {
        engine.update(0.25f);

        if (i > 5) {
            engine.removeSystem(movementSystem);
        }
    }

    engine.removeEntityListener(listener);
}
 
开发者ID:grum,项目名称:Ashley,代码行数:36,代码来源:BasicTest.java

示例7: create

import com.badlogic.ashley.core.PooledEngine; //导入方法依赖的package包/类
@Override
public void create() {
    OrthographicCamera camera = new OrthographicCamera(640, 480);
    camera.position.set(320, 240, 0);
    camera.update();

    Texture crateTexture = new Texture("assets/crate.png");
    Texture coinTexture = new Texture("assets/coin.png");

    engine = new PooledEngine();
    engine.addSystem(new RenderSystem(camera));
    engine.addSystem(new MovementSystem());

    Entity crate = engine.createEntity();
    crate.add(new PositionComponent(50, 50));
    crate.add(new VisualComponent(new TextureRegion(crateTexture)));

    engine.addEntity(crate);

    TextureRegion coinRegion = new TextureRegion(coinTexture);

    for (int i = 0; i < 100; i++) {
        Entity coin = engine.createEntity();
        coin.add(new PositionComponent(MathUtils.random(640), MathUtils.random(480)));
        coin.add(new MovementComponent(10.0f, 10.0f));
        coin.add(new VisualComponent(coinRegion));
        engine.addEntity(coin);
    }
}
 
开发者ID:grum,项目名称:Ashley,代码行数:30,代码来源:RenderSystemTest.java

示例8: main

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

    CounterSystem counter = new CounterSystem();
    IgnoredSystem ignored = new IgnoredSystem();

    engine.addSystem(counter);
    engine.addSystem(ignored);

    for (int i = 0; i < 10; i++) {
        engine.update(0.25f);
    }
}
 
开发者ID:grum,项目名称:Ashley,代码行数:14,代码来源:IgnoreSystemTest.java

示例9: setupEngine

import com.badlogic.ashley.core.PooledEngine; //导入方法依赖的package包/类
@Override
protected void setupEngine(PooledEngine engine, SpriteBatch batch) {
    super.setupEngine(engine, batch);
    engine.addSystem(new NetworkSystem(ServiceLocator.getAppComponent().getNetworkService()));
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:6,代码来源:MpGamePresenter.java

示例10: show

import com.badlogic.ashley.core.PooledEngine; //导入方法依赖的package包/类
@Override
public void show() {
    // ui
    hud = new HudScene(spriteBatch, shapeRenderer, arcRenderer);

    //input
    InputMultiplexer multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(hud.getStage());
    multiplexer.addProcessor(new GestureDetector(new GameGestureProcessor(this)));
    multiplexer.addProcessor(new GameInputProcessor(this));
    Gdx.input.setInputProcessor(multiplexer);

    // map
    map = new TmxMapLoader().load("maps/" + level.getFile());

    mapHeight = map.getProperties().get("height", 40, int.class);
    mapWidth = map.getProperties().get("width", 15, int.class);

    tilewidth = map.getProperties().get("tilewidth", 128, int.class);

    // renderer
    float unitScale = 1 / (float) tilewidth;
    tiledMapRenderer = new OrthogonalTiledMapRenderer(map, unitScale);

    // camera
    camera = new OrthographicCamera();
    camera.setToOrtho(false, mapWidth, mapHeight);
    camera.update();

    // ecs
    engine = new PooledEngine();
    engine.addSystem(new WaveSystem(level));
    engine.addSystem(new SpawnSystem(engine, mapHeight, 5.5f));
    engine.addSystem(turretSystem = new TurretSystem());
    engine.addSystem(pathFindingSystem = new PathFindingSystem(mapHeight, mapWidth, map));
    engine.addSystem(new MoveToSystem());
    engine.addSystem(new MovementSystem());
    engine.addSystem(new RenderSystem(camera, tilewidth));

    loadSprites();
    setupEntities();

    pathFindingSystem.init(new Vector2(39.5f, mapHeight - 10 + 0.5f));
}
 
开发者ID:MiniDigger,项目名称:projecttd,代码行数:45,代码来源:GameScreen.java

示例11: GameScreen

import com.badlogic.ashley.core.PooledEngine; //导入方法依赖的package包/类
public GameScreen(RebelInvader game) {
    this.game = game;

    state = GAME_RUNNING;

    engine = new PooledEngine();
    level = new Level(engine);
    world = new World(new Vector2(0, 0), true);
    listener = new PhysicsListener();

    // Testing
    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    touchPoint = new Vector3();
    layout = new GlyphLayout();
    deadEntities = new ArrayList<Entity>();

    currentTime = 0f;
    missilex = 0f;
    powerActivated = false;

    engine.addSystem(new PlayerSystem(level));
    engine.addSystem(new CameraSystem());
    engine.addSystem(new BackgroundSystem());
    engine.addSystem(new MovementSystem());
    engine.addSystem(new BoundsSystem());
    engine.addSystem(new StateSystem());
    engine.addSystem(new AnimationSystem());
    engine.addSystem(new StructureSystem(level));
    engine.addSystem(new EnemySystem(level));
    engine.addSystem(new RenderingSystem(game.batch));
    engine.addSystem(new PhysicsSystem(world, engine.getSystem(RenderingSystem.class).getCamera()));
    engine.addSystem(new HealthSystem(this));
    engine.addSystem(new PowerSystem(this));
    engine.addSystem(new HeightDisposableSystem(this));
    engine.addSystem(new BulletSystem(this));
    engine.addSystem(new MissileSystem(this, level));
    engine.addSystem(new ExplosionSystem(this));

    // Set camera
    engine.getSystem(BackgroundSystem.class).setCamera(engine.getSystem(RenderingSystem.class).getCamera());

    // Set PhysicsListener as the entity listener for Ashley and contact listener for Box2D
    engine.addEntityListener(Family.all(BodyComponent.class).get(), listener);
    world.setContactListener(listener);

    // Set continuous physics for bullets
    world.setContinuousPhysics(true);

    level.create(world);

    pauseBounds = new Rectangle(320 - 40 - 5, 480 - 50 - 5, 40, 50);
    missileBounds = new Rectangle(10, 10, 50, 50);

    resumeSystems();

    Assets.musicMenu.stop();
    Assets.musicGame.play();
}
 
开发者ID:DevelopersGuild,项目名称:rebel-invader,代码行数:60,代码来源:GameScreen.java

示例12: GameScreen

import com.badlogic.ashley.core.PooledEngine; //导入方法依赖的package包/类
public GameScreen (SuperJumper game) {
	this.game = game;

	state = GAME_READY;
	guiCam = new OrthographicCamera(320, 480);
	guiCam.position.set(320 / 2, 480 / 2, 0);
	touchPoint = new Vector3();
	collisionListener = new CollisionListener() {
		@Override
		public void jump () {
			Assets.playSound(Assets.jumpSound);
		}

		@Override
		public void highJump () {
			Assets.playSound(Assets.highJumpSound);
		}

		@Override
		public void hit () {
			Assets.playSound(Assets.hitSound);
		}

		@Override
		public void coin () {
			Assets.playSound(Assets.coinSound);
		}
	};
	
	engine = new PooledEngine();
	
	world = new World(engine);
	
	engine.addSystem(new BobSystem(world));
	engine.addSystem(new SquirrelSystem());
	engine.addSystem(new PlatformSystem());
	engine.addSystem(new CameraSystem());
	engine.addSystem(new BackgroundSystem());
	engine.addSystem(new GravitySystem());
	engine.addSystem(new MovementSystem());
	engine.addSystem(new BoundsSystem());
	engine.addSystem(new StateSystem());
	engine.addSystem(new AnimationSystem());
	engine.addSystem(new CollisionSystem(world, collisionListener));
	engine.addSystem(new RenderingSystem(game.batcher));
	
	engine.getSystem(BackgroundSystem.class).setCamera(engine.getSystem(RenderingSystem.class).getCamera());
	
	world.create();
	
	pauseBounds = new Rectangle(320 - 64, 480 - 64, 64, 64);
	resumeBounds = new Rectangle(160 - 96, 240, 192, 36);
	quitBounds = new Rectangle(160 - 96, 240 - 36, 192, 36);
	lastScore = 0;
	scoreString = "SCORE: 0";
	
	pauseSystems();
}
 
开发者ID:saltares,项目名称:ashley-superjumper,代码行数:59,代码来源:GameScreen.java


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