本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.Batch.draw方法的典型用法代碼示例。如果您正苦於以下問題:Java Batch.draw方法的具體用法?Java Batch.draw怎麽用?Java Batch.draw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.g2d.Batch
的用法示例。
在下文中一共展示了Batch.draw方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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
}
示例2: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float alpha) {
batch.draw(tile,actorX,actorY);
if(icon != null && animation == NO_ANIMATION)
batch.draw(icon, actorX, actorY);
if(animation == BLACK_ANIMATION)
currentFrame = blackAnimation.getKeyFrame(stateTime, true);
else if(animation == WHITE_ANIMATION)
currentFrame = whiteAnimation.getKeyFrame(stateTime, true);
if(stateTime > ANIMATION_TIME) {
stateTime = 0;
animation = 0;
currentFrame = null;
}
if(currentFrame != null)
batch.draw(currentFrame, actorX, actorY);
}
示例3: 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);
}
示例4: debugMethodRender
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
public void debugMethodRender(Batch batch, Texture texture, Camera offset)
{
for (int i = 0; i < collisionMap.length; i++)
for (int j = 0; j < collisionMap[i].length; j++)
if (collisionMap[i][j] != null)
batch.draw(texture, i + offset.position.x - 50 - offset.viewportWidth / 2,
j + offset.position.y - 50 - offset.viewportHeight / 2, 1, 1);
}
示例5: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
if (map != null) {
Color prev = batch.getColor();
batch.setColor(getColor());
batch.draw(map, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(),
getScaleY(), getRotation());
batch.setColor(prev);
}
}
示例6: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
if (!isVisible()) return;
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
batch.draw(texture, getX() - 10, getY() - 10);
}
示例7: render
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void render(Batch batch, float deltaTime)
{
if (body == null) return;
Color oldColor = batch.getColor();
batch.setColor(1f, (health + 5)/10f, (health + 5)/10f, 1f);
Vector2 pos = body.getPosition();
pos.scl(Physics.PPM);
float scaleX = 1f;
animationTime += deltaTime;
batch.draw(rabbit, // TextureRegion (front, back, side)
pos.x - rabbit.getRegionWidth() / 2, // Offset to the X position (character center)
pos.y, // Y position is at the foots
rabbit.getRegionWidth() / 2, // Origin X (important for flipping)
rabbit.getRegionHeight(), // Origin Y
rabbit.getRegionWidth(), // Width
rabbit.getRegionHeight(), // Height
scaleX, // Scale X (-1 to flip)
1f, // Scale Y
0f); // Rotation
batch.setColor(oldColor);
}
示例8: render
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void render(Batch batch, float deltaTime)
{
if (body == null) return;
Color oldColor = batch.getColor();
batch.setColor(1f, (health + 5)/10f, (health + 5)/10f, 1f);
Vector2 pos = body.getPosition();
pos.scl(Physics.PPM);
TextureRegion region = MathUtils.isZero(hitTimer) ? dummy : dummy_hit;
batch.draw(region, // TextureRegion (front, back, side)
pos.x - dummy.getRegionWidth() / 2, // Offset to the X position (character center)
pos.y, // Y position is at the foots
dummy.getRegionWidth() / 2, // Origin X (important for flipping)
dummy.getRegionHeight(), // Origin Y
dummy.getRegionWidth(), // Width
dummy.getRegionHeight(), // Height
1f, // Scale X (-1 to flip)
1f, // Scale Y
0f); // Rotation
batch.setColor(oldColor);
}
示例9: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
public void draw(Batch batch, float x, float y, float width, float height) {
batch.draw(blank, x, y, width, height);
if (inventory.itemStacks[num] != null) {
TextureRegion region = inventory.itemStacks[num].getTextureRegion();
batch.draw(region, x + 2f, y + 2f, width - 4f, height - 4f);
drawText(batch, x + 2f, y + 2f, inventory.itemStacks[num]);
}
}
示例10: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
public void draw(Batch batch, float x, float y, float width, float height) {
for (int i = 0; i < 9; i++) {
if (i == playerInventory.hotbarSelected) {
batch.draw(hotbarSelected, x + (48f * i), y, 48f, 48f);
} else {
batch.draw(hotbar, x + (48f * i), y, 48f, 48f);
}
if (playerInventory.itemStacks[i] != null) {
TextureRegion region = playerInventory.itemStacks[i].getTextureRegion();
batch.draw(region, x + (48f * i) + 8f, y + 8f, 32f, 32f);
SlotActor.drawText(batch, x + (48f * i) + 8f, y + 8f, playerInventory.itemStacks[i]);
}
}
}
示例11: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float alpha){
float ratio = 1f / ((float)editor.pixmap().getWidth() / editor.pixmap().getHeight());
float size = Math.min(width, height);
float sclwidth = size * zoom;
float sclheight = size * zoom * ratio;
float centerx = x + width/2 + offsetx * zoom;
float centery = y + height/2 + offsety * zoom;
image.setImageSize(editor.pixmap().getWidth(), editor.pixmap().getHeight());
batch.flush();
boolean pop = ScissorStack.pushScissors(Tmp.r1.set(x + width/2 - size/2, y + height/2 - size/2, size, size));
batch.draw(editor.texture(), centerx - sclwidth/2, centery - sclheight/2, sclwidth, sclheight);
if(grid){
Draw.color(Color.GRAY);
image.setBounds(centerx - sclwidth/2, centery - sclheight/2, sclwidth, sclheight);
image.draw(batch, alpha);
Draw.color();
}
if(tool == EditorTool.line && drawing){
Vector2 v1 = unproject(startx, starty).add(x, y);
float sx = v1.x, sy = v1.y;
Vector2 v2 = unproject(lastx, lasty).add(x, y);
Draw.color(Tmp.c1.set(ColorMapper.getColor(editor.getDrawBlock())));
Draw.thick(Unit.dp.scl(3f * zoom));
Draw.line(sx, sy, v2.x, v2.y);
Draw.polygon(sx, sy, 40, editor.getBrushSize() * zoom * 3);
Draw.polygon(v2.x, v2.y, 40, editor.getBrushSize() * zoom * 3);
}
batch.flush();
if(pop) ScissorStack.popScissors();
Draw.color(Colors.get("accent"));
Draw.thick(Unit.dp.scl(3f));
Draw.linerect(x + width/2 - size/2, y + height/2 - size/2, size, size);
Draw.reset();
}
示例12: render
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void render(Batch batch, float deltaTime)
{
if (body == null) return;
Color oldColor = batch.getColor();
batch.setColor(1f, (health + 2)/4f, (health + 2)/4f, 1f);
Vector2 pos = body.getPosition();
pos.scl(Physics.PPM);
TextureRegion region = null;
float scaleX = 1f;
animationTime += deltaTime;
switch (orientation)
{
case LOOK_FORWARD:
region = npcFrontWalk.getKeyFrame(animationTime);
break;
case LOOK_LEFT:
region = npcSideWalk.getKeyFrame(animationTime);
break;
case LOOK_BACKWARD:
region = npcBackWalk.getKeyFrame(animationTime);
scaleX = -1f;
break;
case LOOK_RIGHT:
region = npcSideWalk.getKeyFrame(animationTime);
scaleX = -1f;
break;
}
batch.draw(region, // TextureRegion (front, back, side)
pos.x - region.getRegionWidth() / 2, // Offset to the X position (character center)
pos.y, // Y position is at the foots
region.getRegionWidth() / 2, // Origin X (important for flipping)
region.getRegionHeight(), // Origin Y
region.getRegionWidth(), // Width
region.getRegionHeight(), // Height
scaleX, // Scale X (-1 to flip)
1f, // Scale Y
0f); // Rotation
batch.setColor(oldColor);
}
示例13: renderBackground
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
private void renderBackground(Batch backupBatch)
{
backupBatch.begin();
backupBatch.draw(background, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
backupBatch.end();
}
示例14: render
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void render(Batch batch) {
batch.draw(texture, getPosition().x, getPosition().y, getSize().width, getSize().height);
}
示例15: render
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void render(Batch batch, float deltaTime)
{
if (body == null) return;
Color oldColor = batch.getColor();
batch.setColor(1f, (health + 30)/60f, (health + 30)/60f, 1f);
Vector2 pos = body.getPosition();
pos.scl(Physics.PPM);
TextureRegion region = null;
float scaleX = 1f;
animationTime += deltaTime;
switch (orientation)
{
case LOOK_FORWARD:
region = npcFrontWalk.getKeyFrame(animationTime);
break;
case LOOK_LEFT:
region = npcSideWalk.getKeyFrame(animationTime);
break;
case LOOK_BACKWARD:
region = npcBackWalk.getKeyFrame(animationTime);
scaleX = -1f;
break;
case LOOK_RIGHT:
region = npcSideWalk.getKeyFrame(animationTime);
scaleX = -1f;
break;
}
batch.draw(region, // TextureRegion (front, back, side)
pos.x - region.getRegionWidth() / 2, // Offset to the X position (character center)
pos.y, // Y position is at the foots
region.getRegionWidth() / 2, // Origin X (important for flipping)
region.getRegionHeight(), // Origin Y
region.getRegionWidth(), // Width
region.getRegionHeight(), // Height
scaleX, // Scale X (-1 to flip)
1f, // Scale Y
0f); // Rotation
batch.setColor(oldColor);
}