當前位置: 首頁>>代碼示例>>Java>>正文


Java Batch類代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.Batch的典型用法代碼示例。如果您正苦於以下問題:Java Batch類的具體用法?Java Batch怎麽用?Java Batch使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Batch類屬於com.badlogic.gdx.graphics.g2d包,在下文中一共展示了Batch類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
	if (sprite != null && !sprite.isEmpty() && !sprite.equals(NO_SPRITE)) {
		Sprite render = layer.getGameSprite(sprite);
		render.setPosition(MathUtils.round(getX()), MathUtils.round(getY()));
		render.setRotation(getRotation());
		render.setAlpha(getColor().a * parentAlpha);
		render.setOrigin(getOriginX(), getOriginY());
		render.setColor(getColor());
		render.setSize(getWidth(), getHeight());
		render.setScale(getScaleX(), getScaleY());
		render.setFlip(flip_x, flip_y);
		render.draw(batch);
	}
	super.draw(batch, parentAlpha);
}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:17,代碼來源:GameObject.java

示例2: drawBg

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
public void drawBg(Batch batch, float parentAlpha) {
    batch.end();
    Gdx.gl.glLineWidth(1.0f);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
    Matrix4 matrix = batch.getTransformMatrix();
    shapeRenderer.setTransformMatrix(matrix);

    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    BG.a = parentAlpha;
    shapeRenderer.setColor(BG);
    shapeRenderer.rect(getX(), getY(), getWidth(), getHeight());
    shapeRenderer.end();

    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
    batch.setColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, Color.WHITE.a * parentAlpha);
}
 
開發者ID:whitecostume,項目名稱:libgdx_ui_editor,代碼行數:21,代碼來源:EditingZone.java

示例3: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void draw (Batch batch, float parentAlpha) {
    batch.end();

    Gdx.gl.glLineWidth(10);

    for (PolygonRegion region : polygonRegions) {

        this.batch.begin();
        this.batch.draw(region, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        this.batch.end();

        Polyline line = new Polyline(region.getVertices());
        line.setScale(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
        shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
        shapeRenderer.setColor(Color.BROWN);
        shapeRenderer.polyline(line.getTransformedVertices());
        shapeRenderer.end();
    }

    batch.begin();
}
 
開發者ID:cpppwner,項目名稱:NoRiskNoFun,代碼行數:25,代碼來源:GameObjectMap.java

示例4: render

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void render(Batch batch, float deltaTime)
{
    if (body == null) return;

    batch.draw(bigStone,                                    // TextureRegion
            position.x - bigStone.getRegionWidth() / 2,     // Offset to the X position (character center)
            position.y,                                     // Y position is at the foots
            bigStone.getRegionWidth() / 2,                  // Origin X (important for flipping)
            bigStone.getRegionHeight(),                     // Origin Y
            bigStone.getRegionWidth(),                      // Width
            bigStone.getRegionHeight(),                     // Height
            1f,                                             // Scale X (-1 to flip)
            1f,                                             // Scale Y
            0f);                                            // Rotation
}
 
開發者ID:Entwicklerpages,項目名稱:school-game,代碼行數:17,代碼來源:StoneBarrier.java

示例5: preDraw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
	public void preDraw(Batch batch, float parentAlpha) {
//		boolean last_additive = pre_draws.size > 0?containsAdditive(pre_draws.first()):false;
		
		for (int i = 0; i < pre_draws.size; i++) {
			PooledEffect pe = pre_draws.get(i);
			
//			boolean contains_additive = containsAdditive(pe);
//			if(last_additive&&!contains_additive) {
//				batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
//			}
//			last_additive = contains_additive;
			
			pe.draw(batch);

		}
		
		batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
	}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:20,代碼來源:ParticleSystem.java

示例6: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
	shaderProgram = batch.getShader();
	texture.bind();
	System.arraycopy(initialVertices, 0, operatedVertices, 0, initialVertices.length);
	for (int i=6; i<initialVertices.length; i+=9)
		operatedVertices[i] = parentAlpha * getColor().a;
	mesh.setVertices(operatedVertices);
	mat4_trans.setToRotation(0, 0, 1, getRotation());
	mesh.transform(mat4_trans);
	mat4_trans.setToTranslationAndScaling(getX(), getY(), 0, getWidth() / 2f, -getHeight() / 2f, 1);
	mesh.transform(mat4_trans);
	Gdx.gl.glEnable(GL20.GL_BLEND);
       Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
	mesh.render(shaderProgram, GL20.GL_TRIANGLE_FAN);
}
 
開發者ID:cn-s3bit,項目名稱:TH902,代碼行數:17,代碼來源:CircularDrawingStatic.java

示例7: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
    final float x = getX(), y = getY();

    batch.setColor(theme.background);
    batch.draw(background, x, y, getWidth(), getHeight());

    // Avoid drawing on the borders by adding +1 cell padding
    for (int i = 0; i < colorsUsed.length; ++i) {
        for (int j = 0; j < colorsUsed[i].length; ++j) {
            Cell.draw(theme.cellTexture, theme.getCellColor(colorsUsed[i][j]), batch,
                    x + cellSize * (j + 1), y + cellSize * (i + 1), cellSize);
        }
    }

    super.draw(batch, parentAlpha);
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:18,代碼來源:ThemeCard.java

示例8: postDraw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
	public void postDraw(Batch batch, float parentAlpha) {
//		boolean last_additive = post_draws.size > 0?containsAdditive(post_draws.first()):false;
		for (int i = 0; i < post_draws.size; i++) {
			PooledEffect pe = post_draws.get(i);
//			boolean contains_additive = containsAdditive(pe);
//			if(last_additive&&!contains_additive) {
//				batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
//			}
//			last_additive = contains_additive;
			
			pe.draw(batch);
		}
		
		batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
		
	}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:18,代碼來源:ParticleSystem.java

示例9: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
    final float x = getX(), y = getY();

    batch.setColor(Klooni.theme.background);
    batch.draw(background, x, y, getWidth(), getHeight());

    // Avoid drawing on the borders by adding +1 cell padding
    board.pos.set(x + cellSize * 1, y + cellSize * 1);

    // Draw only if effects are done, i.e. not showcasing
    if (board.effectsDone())
        board.draw(batch);

    super.draw(batch, parentAlpha);
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:17,代碼來源:EffectCard.java

示例10: showcase

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public boolean showcase(Batch batch, float yDisplacement) {
    board.pos.y += yDisplacement;

    // If no effect is running
    if (board.effectsDone()) {
        // And we want to create a new one
        if (needCreateEffect) {
            // Clear at cells[1][1], the center one
            board.clearAll(1, 1, effect);
            needCreateEffect = false;
        } else {
            // Otherwise, the previous effect finished, so return false because we're done
            // We also want to draw the next time so set the flag to true
            setRandomPiece();
            needCreateEffect = true;
            return false;
        }
    }

    board.draw(batch);
    return true;
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:24,代碼來源:EffectCard.java

示例11: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
	if (background != null) {
		// draw background
		if (size > 1) {
			for (int i = 0; i < size; i++) {
				y = (i % (size / 3)) + yoff;
				x = (i / (size / 3)) + xoff;
				x_check = pos_x + (getWidth() * x);
				y_check = pos_y + (getHeight() * y);
				batch.draw(background, MathUtils.floor(getX() + x_check),MathUtils.floor( getY() + y_check), getWidth(), getHeight());
			}
		} else {
			batch.draw(background, MathUtils.floor(getX() + pos_x), MathUtils.floor(getY() + pos_y), getWidth(), getHeight());
		}

	}
	super.draw(batch, parentAlpha);
}
 
開發者ID:kyperbelt,項目名稱:KyperBox,代碼行數:20,代碼來源:ScrollingBackground.java

示例12: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void draw(Batch batch) {
    age += Gdx.graphics.getDeltaTime();

    final float progress = age * INV_LIFETIME;
    final float currentSize = Interpolation.pow2In.apply(size, 0, progress);
    final float currentRotation = Interpolation.sine.apply(0, TOTAL_ROTATION, progress);

    final Matrix4 original = batch.getTransformMatrix().cpy();
    final Matrix4 rotated = batch.getTransformMatrix();

    final float disp =
            + 0.5f * (size - currentSize) // the smaller, the more we need to "push" to center
            + currentSize * 0.5f; // center the cell for rotation

    rotated.translate(pos.x + disp, pos.y + disp, 0);
    rotated.rotate(0, 0, 1, currentRotation);
    rotated.translate(currentSize * -0.5f, currentSize * -0.5f, 0); // revert centering for rotation

    batch.setTransformMatrix(rotated);
    Cell.draw(color, batch, 0, 0, currentSize);
    batch.setTransformMatrix(original);
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:24,代碼來源:SpinEffect.java

示例13: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void draw(Batch batch) {
    vanishElapsed += Gdx.graphics.getDeltaTime();

    // Update the size as we fade away
    final float progress = vanishElapsed * INV_LIFETIME;
    vanishSize = Interpolation.fade.apply(size, 0, progress);

    // Fade away depending on the time
    vanishColor.set(vanishColor.r, vanishColor.g, vanishColor.b, 1.0f - progress);

    // Ghostly fade upwards, by doing a lerp from our current position to the wavy one
    pos.x = MathUtils.lerp(
            pos.x,
            originalX + MathUtils.sin(randomOffset + vanishElapsed * 3f) * driftMagnitude,
            0.3f
    );
    pos.y += UP_SPEED * Gdx.graphics.getDeltaTime();

    Cell.draw(vanishColor, batch, pos.x, pos.y, vanishSize);
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:22,代碼來源:EvaporateEffect.java

示例14: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void draw(Batch batch) {
    final float dt = Gdx.graphics.getDeltaTime();
    fallSpeed += fallAcceleration * dt;
    pos.y -= fallSpeed * dt;

    cellColor.set(
            cellColor.r, cellColor.g, cellColor.b,
            Math.max(cellColor.a - COLOR_SPEED * dt, 0.0f)
    );
    dropColor.set(
            cellColor.r, cellColor.g, cellColor.b,
            Math.min(dropColor.a + COLOR_SPEED * dt, 1.0f)
    );

    Cell.draw(cellColor, batch, pos.x, pos.y, cellSize);
    Cell.draw(dropTexture, dropColor, batch, pos.x, pos.y, cellSize);

    final Vector3 translation = batch.getTransformMatrix().getTranslation(new Vector3());
    dead = translation.y + pos.y + dropTexture.getHeight() < 0;
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:22,代碼來源:WaterdropEffect.java

示例15: draw

import com.badlogic.gdx.graphics.g2d.Batch; //導入依賴的package包/類
@Override
public void draw(Batch batch) {
    vanishElapsed += Gdx.graphics.getDeltaTime();

    // vanishElapsed might be < 0 (delay), so clamp to 0
    float progress = Math.min(1f,
            Math.max(vanishElapsed, 0f) / vanishLifetime);

    // If one were to plot the elasticIn function, they would see that the slope increases
    // a lot towards the end- a linear interpolation between the last size + the desired
    // size at 20% seems to look a lot better.
    vanishSize = MathUtils.lerp(
            vanishSize,
            Interpolation.elasticIn.apply(cell.size, 0, progress),
            0.2f
    );

    float centerOffset = cell.size * 0.5f - vanishSize * 0.5f;
    Cell.draw(vanishColor, batch, cell.pos.x + centerOffset, cell.pos.y + centerOffset, vanishSize);
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:21,代碼來源:VanishEffect.java


注:本文中的com.badlogic.gdx.graphics.g2d.Batch類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。