示例#1
0
  Menu(TwoD game) {
    this.game = game;
    batch = new SpriteBatch();
    font = new BitmapFont();
    font.setColor(Color.WHITE);
    camera = new OrthographicCamera();
    viewport = new FitViewport(1024, 786, camera);
    viewport.apply();
    stage = new Stage(viewport, batch);

    stage.setDebugAll(true);

    gearScreen = new GearScreen();
    gearScreen.setBounds(512, 0, 512, 786);

    inventoryScreen = new InventoryScreen();
    inventoryScreen.setBounds(0, 0, 512, 786);

    stage.addActor(gearScreen);
    stage.addActor(inventoryScreen);
    dnd = new DragAndDrop();

    inputMultiplexer = new InputMultiplexer();
    inputMultiplexer.addProcessor(this);
    inputMultiplexer.addProcessor(stage);
  }
示例#2
0
  @Override
  public void render(float delta) {
    viewport.apply();
    Constants.setBG();

    batch.setProjectionMatrix(viewport.getCamera().combined);

    batch.begin();

    final GlyphLayout easyLayout = new GlyphLayout(font, Constants.EASY_LABEL);
    font.setColor(Color.BLACK);
    font.draw(
        batch,
        Constants.EASY_LABEL,
        Constants.EASY_CENTER.x,
        Constants.EASY_CENTER.y + easyLayout.height / 2,
        0,
        Align.center,
        false);

    final GlyphLayout mediumLayout = new GlyphLayout(font, Constants.MEDIUM_LABEL);
    font.draw(
        batch,
        Constants.MEDIUM_LABEL,
        Constants.MEDIUM_CENTER.x,
        Constants.MEDIUM_CENTER.y + mediumLayout.height / 2,
        0,
        Align.center,
        false);

    final GlyphLayout hardLayout = new GlyphLayout(font, Constants.HARD_LABEL);
    font.draw(
        batch,
        Constants.HARD_LABEL,
        Constants.HARD_CENTER.x,
        Constants.HARD_CENTER.y + hardLayout.height / 2,
        0,
        Align.center,
        false);

    batch.end();
  }
 @Override
 protected void processEntity(Entity entity, float deltaTime) {
   PositionComponent position = positionMapper.get(entity);
   OutOfBoundsComponent outOfBounds = outOfBoundsMapper.get(entity);
   if (position.x > viewport.getWorldWidth() / 2
       || position.x < -viewport.getWorldWidth() / 2
       || position.y > viewport.getWorldHeight() / 2
       || position.y < -viewport.getWorldHeight() / 2) {
     if (outOfBounds.action == AdequateAction.RESPAWN) {
       position.x = MathUtils.random(-viewport.getWorldWidth() / 2, viewport.getWorldWidth() / 2);
       position.y =
           MathUtils.random(-viewport.getWorldHeight() / 2, viewport.getWorldHeight() / 2);
     } else if (outOfBounds.action == AdequateAction.ALERT) {
       lightsManager.ambientLight = 0.1f;
     } else if (outOfBounds.action == AdequateAction.DISPOSE) {
       BodyComponent body = bodyMapper.get(entity);
       if (body != null) bodyGenerator.destroyBody(entity);
       engine.removeEntity(entity);
     }
   }
 }
示例#4
0
  @Override
  public void show() {
    // Initialize and create viewport and camera
    viewport.apply();

    shapeCreator = new ShapeRenderer();
    myBatch = new SpriteBatch();
    user_locations = new ArrayList<Vector2>();
    set_up_positions();

    // Create stage
    game_stage = new Game_Stage();
    game_stage.setViewport(viewport);

    // Sprite creation
    card_back = new Sprite(new Texture("card_images/vertical_cardback.png"));
    card_back.setPosition(user_locations.get(13).x, user_locations.get(13).y);

    // set input processor to the main menu stage
    Gdx.input.setInputProcessor(game_stage);
  }
示例#5
0
  @Override
  public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    // TODO: Unproject the touch from the screen to the world
    Vector2 worldTouch = viewport.unproject(new Vector2(screenX, screenY));

    // TODO: Check if the touch was inside a button, and launch the icicles screen with the
    // appropriate difficulty

    if (worldTouch.dst(Constants.EASY_CENTER) < Constants.DIFFICULTY_BUBBLE_RADIUS) {
      game.showGameScreen(Constants.Difficulty.EASY);
    }

    if (worldTouch.dst(Constants.MEDIUM_CENTER) < Constants.DIFFICULTY_BUBBLE_RADIUS) {
      game.showGameScreen(Constants.Difficulty.MEDIUM);
    }

    if (worldTouch.dst(Constants.HARD_CENTER) < Constants.DIFFICULTY_BUBBLE_RADIUS) {
      game.showGameScreen(Constants.Difficulty.HARD);
    }

    return true;
  }
示例#6
0
 public void resize(int width, int height) {
   viewport.update(width, height);
 }
示例#7
0
 @Override
 public void resize(int width, int height) {
   viewport.update(width, height, true);
 }