当前位置: 首页>>代码示例>>Java>>正文


Java SpriteBatch.flush方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.SpriteBatch.flush方法的典型用法代码示例。如果您正苦于以下问题:Java SpriteBatch.flush方法的具体用法?Java SpriteBatch.flush怎么用?Java SpriteBatch.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.g2d.SpriteBatch的用法示例。


在下文中一共展示了SpriteBatch.flush方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void draw(GameTime time, SpriteBatch batch) {
    // set camera projection matrix
    batch.setProjectionMatrix(game.getUICamera().combined);

    // draw background
    batch.draw(this.bgImage, 0, 0, game.getViewportWidth(), game.getViewportHeight());

    // draw first (SpriteBatch) layer of HUD
    this.hud.drawLayer0(time, batch);
    batch.flush();
    batch.end();

    // draw second layer (ShapeRenderer) of HUD
    this.shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    this.shapeRenderer.setProjectionMatrix(game.getUICamera().combined);
    this.hud.drawLayer1(time, this.shapeRenderer);
    this.shapeRenderer.end();

    // draw last (SpriteBatch) layer of HUD
    batch.begin();
    batch.setProjectionMatrix(game.getUICamera().combined);
    this.hud.drawLayer2(time, batch);
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:25,代码来源:MainMenuScreen.java

示例2: draw

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void draw(GameTime time, SpriteBatch batch) {
    // draw skybox
    this.skyBox.draw(time, game.getCamera(), batch);

    // set camera projection matrix
    batch.setProjectionMatrix(game.getCamera().getCombined());

    // draw entities
    this.ecs.draw(time, game.getCamera(), batch);

    // reset shader
    batch.setShader(null);
    batch.setProjectionMatrix(game.getCamera().getCombined());

    // draw abilities and so on
    this.ecs.drawUILayer(time, game.getCamera(), batch);

    batch.flush();

    // reset shader, so default shader is used
    batch.setShader(null);

    batch.end();

    this.shapeRenderer.setProjectionMatrix(game.getCamera().getCombined());
    this.shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
    this.shapeRenderer.setColor(Color.BLACK);

    // draw collision boxes
    if (debug) {
        this.collisionManager.drawCollisionBoxes(time, game.getCamera(), shapeRenderer, COLLISION_BOX_COLOR,
                IN_COLLISION_COLOR);
    }

    this.shapeRenderer.end();

    batch.begin();
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:40,代码来源:GameScreen.java

示例3: draw

import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void draw(GameTime time, SpriteBatch batch) {
    // set UI camera
    batch.setProjectionMatrix(game.getUICamera().combined);

    // draw time text
    if (seconds >= 0 && seconds <= 3 && this.elapsedTime > 5000) {
        this.font2.draw(batch, this.timeText, game.getViewportWidth() - 220, game.getViewportHeight() - 50);
    } else {
        this.font1.draw(batch, this.timeText, game.getViewportWidth() - 220, game.getViewportHeight() - 50);
    }

    // draw ammo hud
    this.font2.draw(batch, this.torpedoAmountText, game.getViewportWidth() - 220, 70);
    this.font1.draw(batch, this.torpedoAmountText, game.getViewportWidth() - 220, 70);

    // draw score
    font2.draw(batch, scoreText, 30, game.getViewportHeight() - 50);
    font1.draw(batch, scoreText, 30, game.getViewportHeight() - 50);

    // draw first (SpriteBatch) layer of HUD
    this.hud.drawLayer0(time, batch);
    batch.flush();
    batch.end();

    // draw second layer (ShapeRenderer) of HUD
    this.shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    this.shapeRenderer.setProjectionMatrix(game.getUICamera().combined);
    this.hud.drawLayer1(time, this.shapeRenderer);
    this.shapeRenderer.end();

    this.shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
    this.shapeRenderer.setColor(Color.WHITE);
    this.shapeRenderer.rect(game.getViewportWidth() - 100, 20, 80, 80);

    this.shapeRenderer.end();

    // draw last (SpriteBatch) layer of HUD
    batch.begin();
    batch.setProjectionMatrix(game.getUICamera().combined);
    this.hud.drawLayer2(time, batch);

    // draw torpedo, if available
    if (weaponInvComponent.canShootNowWithRightWeapon()) {
        batch.draw(this.torpedoTexture, game.getViewportWidth() - 91, 30);
    }
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:48,代码来源:HUDOverlayScreen.java


注:本文中的com.badlogic.gdx.graphics.g2d.SpriteBatch.flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。