本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.SpriteBatch.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java SpriteBatch.dispose方法的具体用法?Java SpriteBatch.dispose怎么用?Java SpriteBatch.dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g2d.SpriteBatch
的用法示例。
在下文中一共展示了SpriteBatch.dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveChallengeImage
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
public boolean saveChallengeImage(final int score, final boolean timeMode) {
final File saveAt = getShareImageFilePath();
if (!saveAt.getParentFile().isDirectory())
if (!saveAt.mkdirs())
return false;
final FileHandle output = new FileHandle(saveAt);
final Texture shareBase = new Texture(Gdx.files.internal("share.png"));
final int width = shareBase.getWidth();
final int height = shareBase.getHeight();
final FrameBuffer frameBuffer = new FrameBuffer(Pixmap.Format.RGB888, width, height, false);
frameBuffer.begin();
// Render the base share texture
final SpriteBatch batch = new SpriteBatch();
final Matrix4 matrix = new Matrix4();
matrix.setToOrtho2D(0, 0, width, height);
batch.setProjectionMatrix(matrix);
Gdx.gl.glClearColor(Color.GOLD.r, Color.GOLD.g, Color.GOLD.b, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(shareBase, 0, 0);
// Render the achieved score
final Label.LabelStyle style = new Label.LabelStyle();
style.font = new BitmapFont(Gdx.files.internal("font/x1.0/geosans-light64.fnt"));
Label label = new Label("just scored " + score + " on", style);
label.setColor(Color.BLACK);
label.setPosition(40, 500);
label.draw(batch, 1);
label.setText("try to beat me if you can");
label.setPosition(40, 40);
label.draw(batch, 1);
if (timeMode) {
Texture timeModeTexture = new Texture("ui/x1.5/stopwatch.png");
batch.setColor(Color.BLACK);
batch.draw(timeModeTexture, 200, 340);
}
batch.end();
// Get the framebuffer pixels and write them to a local file
final byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, width, height, true);
final Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
PixmapIO.writePNG(output, pixmap);
// Dispose everything
pixmap.dispose();
shareBase.dispose();
batch.dispose();
frameBuffer.end();
return true;
}