Пример #1
0
  private AudioDebugRenderer() {
    listenerTexture = new Texture(Gdx.files.classpath(listenerTextureLocation));
    listenerTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    listenerSprite = new Sprite(listenerTexture);
    listenerSprite.setSize(0.2f, 0.2f);
    listenerSprite.setOriginCenter();

    speakerTexture = new Texture(Gdx.files.classpath(speakerTextureLocation));
    speakerTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    speakerSprite = new Sprite(speakerTexture);
    speakerSprite.setSize(0.2f, 0.2f);
    speakerSprite.setOriginCenter();

    EventService.subscribe(this);
  }
Пример #2
0
  public void draw(Batch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);
    rotation = (rotation + 0);
    sprite.setSize(screenRectangle.width, screenRectangle.height);
    sprite.setPosition(screenRectangle.x, screenRectangle.y);
    sprite.setOriginCenter();

    if (Gdx.input.isKeyJustPressed(keyRight)) {
      body.setTransform(body.getPosition().x + 5, body.getPosition().y, body.getAngle());
    }

    elapsedTime += Gdx.graphics.getDeltaTime();
    // body.setTransform(body.getPosition(), rotation);
    batch.end();
    batch.begin();

    sprite.setRotation(rotation);
    sprite.draw(batch);

    // batch.draw(animation.getKeyFrame(elapsedTime, true), screenRectangle.x, screenRectangle.y,
    // screenRectangle.width, screenRectangle.height );
    // animation.setFrameDuration(0.09f);

  }
Пример #3
0
  @Override
  public void start() {
    OwnedObjectData data = new OwnedObjectData();

    data.drawAfter = true;

    if (bullet.getTicksAlive() < 20) animationPlaying = true;

    createTick = game.getTick();

    bullet.addOwnedObject(this, data);

    final Sprite current = (Sprite) this.ani.getKeyFrame(getTicksAlive());

    Polygon hitbox = bullet.getHitbox();
    Rectangle rect =
        hitbox != null ? hitbox.getBoundingRectangle() : current.getBoundingRectangle();

    final float modifier = 3f;
    float width = rect.getWidth() * modifier;
    float height = rect.getHeight() * modifier;

    final float scaleX = width / current.getWidth();
    final float scaleY = height / current.getHeight();

    current.setScale(scaleX, scaleY);
    current.setRotation(bullet.getRotationDeg());

    current.setOriginCenter();

    Color c = bullet.getDeletionColor().cpy();

    float min = Math.min(c.g, Math.min(c.r, c.b));
    c.r -= min;
    c.g -= min;
    c.b -= min;

    float mul = 0.8f;
    float start = (1f - mul) + 0.3f;

    Color color = new Color(start + (c.r * mul), start + (c.g * mul), start + (c.b * mul), 0f);

    current.setColor(color);
    current.setAlpha(1f);

    final SaveableObject<ScaleAlphaPhaseAnimation> sani =
        new SaveableObject<ScaleAlphaPhaseAnimation>();

    Getter<Sprite> getter =
        new Getter<Sprite>() {
          @Override
          public Sprite get() {
            Sprite current = (Sprite) ani.getKeyFrame(getTicksAlive());

            int over = 5;

            int ticks = (int) ((time.toTicks() - over) - getTicksAlive());

            double mul = 1f - (ticks <= 0 ? -(float) ticks / over : 0f);

            ScaleAlphaPhaseAnimation ani = sani.getObject();

            if (ani == null) return current;

            if (ticks <= 0) {
              animationPlaying = false;
              ani.setAlpha((float) Math.max(0, mul));
            }

            current.setPosition(
                bullet.getX() - current.getWidth() / 2f, bullet.getY() - current.getHeight() / 2f);

            current.setOriginCenter();

            current.setRotation(bullet.getRotationDeg());

            return current;
          }
        };

    final ScaleAlphaPhaseAnimation ani = new ScaleAlphaPhaseAnimation(getter, bullet);

    sani.setObject(ani);

    ani.setTime(time);
    ani.setAddedScale(scaleX * 3f, scaleY * 3f);
    ani.setAlpha(-0.1f);
    ani.start();

    bullet.removeOwnedObject(ani);
    bullet.addOwnedObject(ani, data);
  }