本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch类的典型用法代码示例。如果您正苦于以下问题:Java PolygonSpriteBatch类的具体用法?Java PolygonSpriteBatch怎么用?Java PolygonSpriteBatch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PolygonSpriteBatch类属于com.badlogic.gdx.graphics.g2d包,在下文中一共展示了PolygonSpriteBatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCommand
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void onCommand(PolygonSpriteBatch batch) {
if(_shaderProgram == null) {
ShaderProgram p = GLProgramCache.getInstance().getSpriteBatchDefaultProgram();
if(batch.getShader() != p) {
batch.setShader(null);
}
} else {
if(batch.getShader() != _shaderProgram) {
batch.setShader(_shaderProgram);
}
}
if(_sprite.getTexture() != null) {
_sprite.draw(batch);
}
}
示例2: GameObjectMap
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
GameObjectMap(AssetMap assetMap) {
this.assetMap = assetMap;
batch = new PolygonSpriteBatch();
shapeRenderer = new ShapeRenderer();
Pixmap pix = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
pix.setColor(Color.WHITE);
pix.fill();
texture = new Texture(pix);
regionMap = new HashMap<>();
regionNameMap = new HashMap<>();
initPolygonRegions();
}
示例3: Water
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
/**
* Constructor that allows to specify if there is an effect of waves and splash particles.
* @param waves Specifies whether the object will have waves
* @param splashParticles Specifies whether the object will have splash particles
*/
public Water(boolean waves, boolean splashParticles) {
this.waves = waves;
this.splashParticles = splashParticles;
this.fixturePairs = new HashSet<Pair<Fixture, Fixture>>();
this.setDebugMode(false);
if (waves) {
textureWater = new TextureRegion(new Texture(Gdx.files.internal("water.png")));
polyBatch = new PolygonSpriteBatch();
}
if (splashParticles) {
textureDrop = new Texture(Gdx.files.internal("drop.png"));
spriteBatch = new SpriteBatch();
particles = new ArrayList<Particle>();
}
shapeBatch = new ShapeRenderer();
shapeBatch.setColor(0, 0.5f, 1, 1);
}
示例4: draw
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void draw(GameMapRenderer renderer, float deltaTime) {
super.draw(renderer, deltaTime);
if (!hasSprite()) {
PlayerCharacterController controller = gameState.getPlayerCharacterController();
Tool activeTool = controller.getActiveTool();
PolygonSpriteBatch spriteBatch = renderer.getSpriteBatch();
int src = spriteBatch.getBlendSrcFunc();
int dst = spriteBatch.getBlendDstFunc();
if (src != GL20.GL_SRC_ALPHA || dst != GL20.GL_ONE) {
spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE);
}
spriteBatch.setColor(isHovered() && activeTool == Tool.DISARM ? ColorUtil.GREEN_SEVENFIVE : ColorUtil.RED_SEVENFIVE);
polygonRenderer.render(spriteBatch);
if (src != GL20.GL_SRC_ALPHA || dst != GL20.GL_ONE) {
spriteBatch.setBlendFunction(src, dst);
}
}
}
示例5: show
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void show () {
font = new BitmapFont(Gdx.files.internal("fonts/font.fnt"));
cache = font.getCache();
if (Gdx.app.getType() == ApplicationType.Android)
font.getData().setScale(2);
polygonBatch = new PolygonSpriteBatch();
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Pixmap pixMap = new Pixmap(1, 1, Format.RGB565);
pixMap.setColor(Color.WHITE);
pixMap.fill();
emptyTexture = new Texture(pixMap);
pixMap.dispose();
}
示例6: create
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void create () {
texture = new Texture(Gdx.files.internal("data/tree.png"));
PolygonRegionLoader loader = new PolygonRegionLoader();
region = loader.load(new TextureRegion(texture), Gdx.files.internal("data/tree.psh"));
// create a region from an arbitrary set of vertices (a triangle in this case)
region2 = new PolygonRegion(new TextureRegion(texture), new float[] {0, 0, 100, 100, 0, 100}, new short[] {0, 1, 2});
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.position.x = 0;
camera.position.y = 0;
batch = new PolygonSpriteBatch();
debugRenderer = new PolygonRegionDebugRenderer();
Gdx.input.setInputProcessor(this);
}
示例7: create
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void create () {
texture = new Texture(Gdx.files.internal("data/tree.png"));
PolygonRegionLoader loader = new PolygonRegionLoader();
region = loader.load(new TextureRegion(texture), Gdx.files.internal("data/tree.psh"));
renderer = new ShapeRenderer();
camera = new OrthographicCamera(480, 320);
camera.position.x = 240;
camera.position.y = 160;
camera.update();
batch = new PolygonSpriteBatch();
for (int i = 0; i < 50; i++) {
PolygonSprite sprite = new PolygonSprite(region);
sprite.setPosition(MathUtils.random(-30, 440), MathUtils.random(-30, 290));
sprite.setColor(MathUtils.random(), MathUtils.random(), MathUtils.random(), 1.0f);
sprite.setScale(MathUtils.random(0.5f, 1.5f), MathUtils.random(0.5f, 1.5f));
sprites.add(sprite);
}
}
示例8: createStage
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
protected Stage createStage() {
batch = new PolygonSpriteBatch(2500) {
final int MAX = 2500 * 5;
@Override
public void draw(Texture texture, float[] spriteVertices,
int offset, int count) {
while (count > MAX) {
super.draw(texture, spriteVertices, offset, MAX);
offset += MAX;
count -= MAX;
}
super.draw(texture, spriteVertices, offset, count);
}
};
return new Stage(new ScreenViewport(), batch);
}
示例9: setup
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Before
public void setup() {
mockery = new Mockery();
mockery.setImposteriser(ClassImposteriser.INSTANCE);
gameWrapper = mockery.mock(GameWrapper.class);
spriteBatch = mockery.mock(SpriteBatch.class);
polygonSpriteBatch = mockery.mock(PolygonSpriteBatch.class);
shapeRenderer = mockery.mock(ShapeRenderer.class);
gdxGraphics = mockery.mock(com.badlogic.gdx.Graphics.class);
Gdx.graphics = gdxGraphics;
mockery.checking(new Expectations() {
{
one(gdxGraphics).getWidth();
will(returnValue(800));
one(gdxGraphics).getHeight();
will(returnValue(600));
one(spriteBatch).getColor();
will(returnValue(null));
}
});
graphics = new LibGdxGraphics(gameWrapper, spriteBatch, polygonSpriteBatch, shapeRenderer);
}
示例10: execute
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void execute(Renderer render) {
PolygonSpriteBatch batch = render.batch;
if(!batch.isDrawing()) {
batch.begin();
}
this._callback.onCommand(render.batch);
}
示例11: GameMapRenderer
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
public GameMapRenderer(GameState gameState, GameMap map,
PlayerCharacterController controller) {
this.gameState = gameState;
this.pcc = gameState.getPlayerCharacterController();
this.pcg = GameState.getPlayerCharacterGroup();
/*amplitudeWave = 0.5f;
angleWave = 0;
angleWaveSpeed = 1f;*/
waterShader = WaterShader.createWaterShader();
unitScaleX = map.getScaleX();
unitScaleY = map.getScaleY();
this.map = map;
this.viewBounds = new Rectangle();
this.spriteBatch = new PolygonSpriteBatch();
this.controller = controller;
textBatch = new SpriteBatch();
textBatch.getProjectionMatrix().setToOrtho2D(0, 0,
Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
combatPathRenderer = new CombatPathRenderer(controller);
effectTargetRenderer = new EffectTargetRenderer(controller);
shapeRenderer = new ShapeRenderer(100);
cullingRectangle = new Rectangle();
highlightedDrawables = new ObjectMap<Drawable, Color>();
trapsToDraw = new ObjectMap<TrapLocation, FilledPolygonRenderer>();
trapTiles = new Array<int[]>();
normalColor = Color.toFloatBits(1f, 1f, 1f, 1f);
fogColor = Color.toFloatBits(Configuration.getFogColor().r,
Configuration.getFogColor().g, Configuration.getFogColor().b,
1);
frameBuffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
frameBufferTextureRegion = new TextureRegion();
}
示例12: render
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
public void render(PolygonSpriteBatch batch) {
// lazy init of the polyReg to make sure the map is fully loaded
if (polyReg == null) {
setPolygon(polygon, map);
}
batch.draw(polyReg, 0, 0);
}
示例13: WorldRenderer
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
public WorldRenderer(World world) {
this.world = world;
this.cam = new OrthographicCamera(CAMERA_WIDTH, CAMERA_HEIGHT);
this.cam.position.set(0f, 0f, 0f);
this.cam.update();
spriteBatch = new PolygonSpriteBatch();
renderer = new ShapeRenderer();
layout = new GlyphLayout();
loadTextures();
}
示例14: Terrain
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
public Terrain(){
random = new Random();
shapeRenderer = new ShapeRenderer();
speed = new Vector2(Commons.getInstance().backgroundSpeed);
setPoints(new ArrayList<Vector2>());
setTopPoints(new ArrayList<Vector2>());
setPoints2(new ArrayList<Vector2>());
setTopPoints2(new ArrayList<Vector2>());
getPoints().add(new Vector2(0, Commons.getInstance().initialY));
getPoints().add(new Vector2(Commons.getInstance().deviceWidth, Commons.getInstance().initialY));
getTopPoints().add(new Vector2(0, Commons.getInstance().initialY + Commons.getInstance().wallsDifference));
getTopPoints().add(new Vector2(Commons.getInstance().deviceWidth, Commons.getInstance().initialY + Commons.getInstance().wallsDifference));
getPoints2().add(new Vector2(Commons.getInstance().deviceWidth, Commons.getInstance().initialY));
getPoints2().add(new Vector2(Commons.getInstance().deviceWidth * 2, Commons.getInstance().initialY));
getTopPoints2().add(new Vector2(Commons.getInstance().deviceWidth, Commons.getInstance().initialY + Commons.getInstance().wallsDifference));
getTopPoints2().add(new Vector2(Commons.getInstance().deviceWidth * 2, Commons.getInstance().initialY + Commons.getInstance().wallsDifference));
generateTerrain(1);
generateTerrain(2);
atlas = new TextureAtlas("terrain/textures/textures.pack.atlas");
region = atlas.findRegion("terrain");
batch = new PolygonSpriteBatch();
updatePolygons();
}
示例15: create
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void create () {
instance = this;
Log.debug("Starting loading");
try {
GLFWIconSetter.newInstance().setIcon(Gdx.files.absolute(App.APP_FOLDER_PATH).child("cache/iconCache"),
Gdx.files.internal("icon.ico"), Gdx.files.internal("icon.png"));
} catch (IllegalStateException e) {
Log.exception(e);
}
Assets.load();
VisUI.load();
VisUI.setDefaultTitleAlign(Align.center);
Log.debug("VisUI " + VisUI.VERSION + " loaded");
polygonSpriteBatch = new PolygonSpriteBatch();
stage = createStage();
Gdx.input.setInputProcessor(stage);
uiRoot = new VisTable();
uiRoot.setFillParent(true);
stage.addActor(uiRoot);
createUI();
createModuleContainers();
createModulesUI();
Log.debug("Loading completed");
if (experimentalSettings.isUIScale() || launchConfig.scaleUIEnabled) {
stageViewport.setUnitsPerPixel(0.5f);
}
}