Beispiel #1
0
  private void switch_viewport_to_editor() {
    System.out.println("switched viewport to movie!");

    cam = stage.getCamera();

    stage.setViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
    cam.translate(0, 0, 0);

    cam.update();
  }
Beispiel #2
0
  private void switch_viewport_to_movie() {
    System.out.println("switched viewport to movie!");

    cam = stage.getCamera();

    stage.setViewport(800, 450, true);
    cam.translate(view.MOVIE_DISPLAY_GROUP_OFFSET.x, view.MOVIE_DISPLAY_GROUP_OFFSET.y, 0);

    cam.update();
  }
Beispiel #3
0
 @Override
 public void act(float delta) {
   Char hero = game.getPlayer();
   Visual visual = hero.getVisual();
   float x = visual.x();
   float y = visual.y();
   if (x != preX || y != preY) {
     Camera camera = gameCamera;
     camera.position.set(x, y, 0);
     camera.update();
     preX = x;
     preY = y;
   }
 }
Beispiel #4
0
  public void draw() {
    Camera camera = viewport.getCamera();
    camera.update();

    if (!root.isVisible()) return;

    Batch batch = this.batch;
    if (batch != null) {
      batch.setProjectionMatrix(camera.combined);
      batch.begin();
      root.draw(batch, 1);
      batch.end();
    }

    if (debug) drawDebug();
  }
 /**
  * Renders the given entity
  *
  * @param camera Camera which is used to render the entity
  */
 @Override
 public void render(Camera camera, float delta) {
   super.render(camera, delta);
   if (Gdx.input.isTouched()) {
     Vector3 touchPos = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
     camera.unproject(touchPos);
     setDestination(new Vector2(touchPos.x - 24 / 2, touchPos.y - 24 / 2));
   }
   setHeading(new Vector2(destination).sub(position).nor());
 }
Beispiel #6
0
 public boolean isTouched(float x, float y, Camera camera, Viewport view) {
   Vector3 temp =
       camera.unproject(
           new Vector3(x, y, 0),
           view.getScreenX(),
           view.getScreenY(),
           view.getScreenWidth(),
           view.getScreenHeight());
   return this.getSprite().getBoundingRectangle().contains(temp.x, temp.y);
 }
Beispiel #7
0
  @Override
  public void resize(int width, int height) {
    screenSize.set(width, height);
    midpoint.set(width / 2, height / 2);

    stage2d.getViewport().update(width, height, true);
    setActiveCamera();
    activeCamera.update(true);
    resizeElements();
  }
  @Override
  public void update(Entity entity, MapManager mapMgr, Batch batch, float delta) {
    updateAnimations(delta);

    Camera camera = mapMgr.getCamera();
    camera.position.set(currentPosition.x, currentPosition.y, 0f);
    camera.update();

    batch.begin();
    batch.draw(currentFrame, currentPosition.x, currentPosition.y, 1, 1);
    batch.end();

    // Used to graphically debug boundingboxes
    /*
    Rectangle rect = entity.getCurrentBoundingBox();
    _shapeRenderer.setProjectionMatrix(camera.combined);
    _shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    _shapeRenderer.setColor(Color.RED);
    _shapeRenderer.rect(rect.getX() * Map.UNIT_SCALE , rect.getY() * Map.UNIT_SCALE, rect.getWidth() * Map.UNIT_SCALE, rect.getHeight()*Map.UNIT_SCALE);
    _shapeRenderer.end();
    */
  }
  public void draw(Camera camera) {
    if (this.enabled) {
      Vector3 position = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
      camera.unproject(position);

      //			E.batch.begin();
      E.batch.draw(
          texture,
          position.x + texture.getRegionWidth() / 2,
          position.y - texture.getRegionHeight() / 2);
      //			E.batch.end();
    }
  }
 public void update(float deltaTime) {
   camera.update();
   if (DebugViewSettings.drawModels) {
     drawShadowBatch();
     viewport.apply();
     modelBatch.begin(camera);
     modelBatch.render(engine.getModelCache(), environment);
     for (GameModel mdl : engine.getDynamicModels()) {
       if (isVisible(camera, mdl)) {
         modelBatch.render(mdl.modelInstance, environment);
       }
     }
     if (markerBillboard != null && isVisible(camera, markerBillboard)) {
       modelBatch.render(markerBillboard.modelInstance, environment);
     }
     modelBatch.end();
   }
   if (DebugViewSettings.drawArmature) {
     shapeRenderer.setProjectionMatrix(viewport.getCamera().combined);
     armatureDebugDrawer.drawArmature(shapeRenderer, selectedCharacter, "armature");
   }
   if (DebugViewSettings.drawSteering) {
     drawSteering();
   }
   if (DebugViewSettings.drawNavmesh) {
     shapeRenderer.setProjectionMatrix(viewport.getCamera().combined);
     navMeshDebugDrawer.drawNavMesh(
         shapeRenderer,
         spriteBatch,
         engine.getScene().navMesh,
         selectedCharacter,
         visibleLayers,
         viewport.getCamera(),
         font);
   }
   if (DebugViewSettings.drawMouseNavMeshPos) {
     shapeRenderer.setProjectionMatrix(viewport.getCamera().combined);
     drawMouseWorldAxis();
   }
 }
Beispiel #11
0
  @Override
  public void render(float delta) {

    camera.update();
    game.batch.setProjectionMatrix(camera.combined);

    if (!launchSoundPlayed) {
      launchSound.play();
      launchSoundPlayed = true;
    }

    // quit game if back pressed on main menu
    if (Gdx.input.isKeyPressed(Input.Keys.BACK)) {
      Gdx.app.exit();
    }

    // don't show sign in button if signed in
    if (resolver.signedIn() && signInButton != null) {
      signInButton.setVisible(false);
    }

    if (!resolver.signedIn() && signInButton != null) {
      signInButton.setVisible(true);
    }

    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    backGround.update();

    game.batch.begin();

    backGround.draw(game.batch);
    game.batch.draw(title, 0, GameConstants.GAME_HEIGHT - title.getHeight());
    table.draw(game.batch, 1);
    game.batch.end();

    stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
    stage.draw();
  }
  public void flush() {
    // if we've already flushed
    if (idx == 0) return;
    // sends our vertex data to the mesh
    mesh.setVertices(verts);

    // no need for depth...
    Gdx.gl.glDepthMask(false);

    // enable blending, for alpha
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    // number of vertices we need to render
    int vertexCount = (idx / NUM_COMPONENTS);

    cam.update();

    // start the shader before setting any uniforms
    shader.begin();

    // update the projection matrix so our triangles are rendered in 2D
    shader.setUniformMatrix("u_projTrans", cam.combined);

    // render the mesh
    mesh.render(shader, RENDER_TYPE, 0, vertexCount);

    shader.end();

    // re-enable depth to reset states to their default
    Gdx.gl.glDepthMask(true);

    // reset index to zero
    idx = 0;

    // reset verts
    Arrays.fill(verts, 0);
  }
Beispiel #13
0
 public boolean isTouched(float x, float y, Camera camera) {
   Vector3 temp = camera.unproject(new Vector3(x, y, 0));
   return this.getSprite().getBoundingRectangle().contains(temp.x, temp.y);
 }