コード例 #1
0
  @Override
  public void render(
      Canvas canvas, Element element, DoublePoint mapCenter, DoublePoint screenSize) {
    super.render(canvas, element, mapCenter, screenSize);
    Spaceship spaceship = (Spaceship) element;

    Matrix matrix = new Matrix();
    matrix.reset();
    matrix.postTranslate(-spaceShipBmp.getWidth() / 2, -spaceShipBmp.getHeight() / 2);
    matrix.postRotate((float) spaceship.getRotation());
    matrix.postTranslate(
        (float) (spaceship.getPosition().x - mapCenter.x + screenSize.x / 2),
        (float) (spaceship.getPosition().y - mapCenter.y + screenSize.y / 2));

    canvas.drawBitmap(spaceShipBmp, matrix, null);
    renderColourRect(canvas, element, mapCenter, screenSize);
  }
コード例 #2
0
  private void renderColourRect(
      Canvas canvas, Element element, DoublePoint mapCenter, DoublePoint screenSize) {
    Spaceship spaceship = (Spaceship) element;

    Paint paint = new Paint();
    paint.setDither(true);
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    paint.setColorFilter(new LightingColorFilter(0x00505050, spaceship.colour().toAndroidColor()));

    Matrix matrix = new Matrix();
    matrix.reset();
    matrix.postTranslate(-rectBmp.getWidth() / 2, -rectBmp.getHeight() / 2);
    matrix.postRotate((float) spaceship.getRotation());
    matrix.postTranslate(
        (float) (spaceship.getPosition().x - mapCenter.x + screenSize.x / 2),
        (float) (spaceship.getPosition().y - mapCenter.y + screenSize.y / 2));
    canvas.drawBitmap(rectBmp, matrix, paint);
  }