Exemplo n.º 1
0
 /**
  * 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());
 }
Exemplo n.º 2
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);
 }
  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();
    }
  }
Exemplo n.º 4
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);
 }