コード例 #1
0
ファイル: Enemy.java プロジェクト: pedja1/SMC-Android
  @Override
  public final void _render(SpriteBatch spriteBatch) {
    if (frozen) {
      // set shader
      float brightness = .5f / (freezeCounterMax / freezeCounter);
      spriteBatch.setShader(Shader.FREEZE_SHADER);
      spriteBatch.getShader().setUniformf("u_contrast", 1.1f);
      spriteBatch.getShader().setUniformf("u_brightness", brightness);

      // set color
      frozenColor.a = FROZEN_COLOR_START_ALPHA / (freezeCounterMax / freezeCounter);
      spriteBatch.setColor(frozenColor);

      // render
      doRender(spriteBatch);

      // reset shader
      spriteBatch.setShader(null);

      // reset color
      spriteBatch.setColor(Color.WHITE);
    } else {
      doRender(spriteBatch);
    }
  }
コード例 #2
0
 private void renderWorld(SpriteBatch batch) {
   worldController.cameraHelper.applyTo(camera);
   batch.setProjectionMatrix(camera.combined);
   batch.begin();
   if (GamePreferences.instance.useMonochromeShader) {
     batch.setShader(shaderMonochrome);
     shaderMonochrome.setUniformf("u_amount", 1.0f);
   }
   worldController.level.render(batch);
   batch.setShader(null);
   batch.end();
   if (DEBUG_DRAW_BOX2D_WORLD) b2debugRenderer.render(worldController.b2world, camera.combined);
 }
コード例 #3
0
ファイル: BillGhost.java プロジェクト: scto/LoggerBill
  public boolean draw(SpriteBatch batch, ShaderProgram ghostShader, float delta) {

    // We will use a wibbly-wobbly shader for bill's ghost
    batch.setShader(ghostShader);
    ghostTime += delta;
    ghostShader.setUniformf("time", ghostTime);
    // ghostShader.setUniformf("resolution", 1.0f, 1.0f);

    sprite.setPosition(x, y);
    sprite.setAlpha(alpha);

    sprite.draw(batch);
    y += delta * 250;
    x -= (MathUtils.sin(y / 100 % 360) * 2) * side;
    alpha = (VIEW_HEIGHT - (y / VIEW_HEIGHT / 2));

    batch.setShader(null); // turn off ghost shader.
    return y <= VIEW_HEIGHT + sprite.getHeight();
  }
コード例 #4
0
  public void render(float delta) {
    updateOrbs(delta);

    blurTargetA.begin();
    Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.setShader(null);
    // resizeBatch(FBO_SIZE, FBO_SIZE);
    renderOrbs(OrbPart.Light);
    blurTargetA.end();

    blurTargetB.begin();
    Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    batch.setShader(blurShader);
    batch.begin();
    blurShader.setUniformf("dir", 1f, 0f);
    fboRegion.setTexture(blurTargetA.getColorBufferTexture());
    batch.draw(fboRegion, 0, 0);
    batch.flush();
    blurTargetB.end();

    generateBackground(delta);

    Gdx.gl.glClearColor(backgroundColor.r, backgroundColor.g, backgroundColor.b, 0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    // resizeBatch(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    batch.end();

    // renderOrbs(OrbPart.Dark);

    batch.begin();
    blurShader.setUniformf("dir", 0f, 1f);
    fboRegion.setTexture(blurTargetB.getColorBufferTexture());
    batch.draw(fboRegion, 0, 0);
    batch.setShader(null);
    batch.end();
  }
コード例 #5
0
  @Override
  public void drawChildren(SpriteBatch batch, float parentAlpha) {
    previousScene.setVisible(true);
    nextScene.setVisible(false);
    super.drawChildren(batch, parentAlpha);
    batch.end();
    nextSceneBuffer.begin();
    batch.begin();

    previousScene.setVisible(false);
    nextScene.setVisible(true);

    super.drawChildren(batch, parentAlpha);
    nextSceneBuffer.end();

    batch.flush();
    batch.setShader(maskShader);
    maskShader.setAttributef("a_offset", offset.x, offset.y, offset.z, 0);
    texture.bind(1);
    Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0);
    Gdx.gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
    batch.draw(nextSceneBuffer.getColorBufferTexture(), 0, 0);
    batch.setShader(null);
  }