示例#1
0
 public void addedToEngine(Engine engine) {
   movedEntities =
       engine.getEntitiesFor(
           Family.getFamilyFor(
               BoundsComponent.class, PositionComponent.class, MovementComponent.class));
   entities = engine.getEntitiesFor(Family.getFamilyFor(BoundsComponent.class));
 }
示例#2
0
  private void updateRunning(float deltaTime) {
    // Implement Pause button check here
    /* See ashley-jumper -> GameScreen -> line 155 */

    ApplicationType appType = Gdx.app.getType();

    float accelX = 0.0f;
    boolean fireMissile = false;
    if (appType == ApplicationType.Android || appType == ApplicationType.iOS) {
      accelX = Gdx.input.getAccelerometerX();
      if (Gdx.input.isTouched()) {
        fireMissile = true;
      }
    } else {
      if (Gdx.input.isKeyPressed(Keys.DPAD_LEFT)) {
        accelX = 5f;
      }
      if (Gdx.input.isKeyPressed(Keys.DPAD_RIGHT)) {
        accelX = -5f;
      }
      if (Gdx.input.isKeyPressed(Keys.F)) {
        fireMissile = true;
      }
    }

    engine.getSystem(DefenderSystem.class).setAccelX(accelX);
    engine.getSystem(DefenderSystem.class).setIsFiring(fireMissile);

    // Check if all aliens are gone
    ImmutableArray<Entity> aliens =
        engine.getEntitiesFor(
            Family.all(
                    AlienComponent.class,
                    BoundsComponent.class,
                    MovementComponent.class,
                    TransformComponent.class,
                    StateComponent.class)
                .get());
    if (aliens.size() == 0) {
      world.state = World.WORLD_STATE_GAME_OVER;
    }
    if (world.state == World.WORLD_STATE_GAME_OVER) {
      state = GAME_OVER;
      pauseSystems();
    }
  }
 @Override
 public void addedToEngine(Engine engine) {
   entities = engine.getEntitiesFor(Family.all(PositionComponent.class).get());
 }
 @Override
 public void addedToEngine(Engine engine) {
   entities =
       engine.getEntitiesFor(Family.all(BodyComponent.class).exclude(PlayerComponent.class).get());
   players = engine.getEntitiesFor(Family.all(PlayerComponent.class).get());
 }
 public void addedToEngine(Engine engine) {
   player = engine.getEntitiesFor(Family.all(PlayerSteerableComponent.class).get());
   entities = engine.getEntitiesFor(Family.all(TalkComponent.class).get());
 }