本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.Batch.setColor方法的典型用法代碼示例。如果您正苦於以下問題:Java Batch.setColor方法的具體用法?Java Batch.setColor怎麽用?Java Batch.setColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.g2d.Batch
的用法示例。
在下文中一共展示了Batch.setColor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
Color color = getColor();
if (hidden) {
color = Color.DARK_GRAY;
} else if (selected) {
color = Assets.select(color);
} else if (hovered) {
color = Assets.highlight(color);
}
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
if (hidden) {
batch.draw(Assets.FOGGY, getX(), getY(), getWidth(), getHeight());
} else {
batch.draw(texture, getX(), getY(), getWidth(), getHeight());
}
if (city != null) {
city.draw(batch, parentAlpha);
}
}
示例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(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);
}
示例4: 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);
}
示例5: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
public void draw (Batch batch, float parentAlpha) {
validate();
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
float x = getX();
float y = getY() + floatAction.getValue();
float scaleX = getScaleX();
float scaleY = getScaleY();
if (drawable instanceof TransformDrawable) {
float rotation = getRotation();
if (scaleX != 1 || scaleY != 1 || rotation != 0) {
((TransformDrawable)drawable).draw(batch, x + imageX, y + imageY, getOriginX() - imageX, getOriginY() - imageY,
imageWidth, imageHeight, scaleX, scaleY, rotation);
return;
}
}
if (drawable != null) drawable.draw(batch, x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
}
示例6: 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);
}
示例7: 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);
}
示例8: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
//Reset spritebatch after alpha action
Color color = batch.getColor();
super.draw(batch, parentAlpha);
batch.setColor(color);
}
示例9: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
Color color = getColor();
batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);
batch.draw(texture, getX(), getY(), getWidth() * getScaleX(), getHeight() * getScaleY());
table.draw(batch, parentAlpha * color.a);
batch.setColor(color.r, color.g, color.b, 1f);
}
示例10: render
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void render(Batch batch) {
Color originalColor = batch.getColor();
batch.setColor(color);
batch.draw(shape.getTexture(), getPosition().x, getPosition().y, getSize().width, getSize().height);
batch.setColor(originalColor);
}
示例11: 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);
}
}
示例12: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
camera.update();
Matrix4 projection = batch.getProjectionMatrix();
// batch.end();
// Gdx.gl.glViewport((int) frame.x, (int) frame.y, (int) frame.width, (int) frame.height);
// batch.setProjectionMatrix(camera.combined);
// batch.begin();
tint.a = parentAlpha;
batch.setColor(tint);
batch.draw(terrain, getX(), getY(), getWidth(), getHeight());
// draw nation layers
if (visibilityLookup.get(Nation.FIRE))
batch.draw(fire, getX(), getY(), getWidth(), getHeight());
if (visibilityLookup.get(Nation.WATER))
batch.draw(water, getX(), getY(), getWidth(), getHeight());
if (visibilityLookup.get(Nation.EARTH))
batch.draw(earth, getX(), getY(), getWidth(), getHeight());
if (visibilityLookup.get(Nation.AIR))
batch.draw(air, getX(), getY(), getWidth(), getHeight());
// batch.end();
// batch.setProjectionMatrix(projection);
// batch.begin();
// Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
示例13: render
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void render(Batch batch, float deltaTime)
{
if (body == null) return;
animationTime += deltaTime;
Color oldColor = batch.getColor();
batch.setColor(1f, (health + 4)/8f, (health + 4)/8f, 1f);
Vector2 pos = body.getPosition();
pos.scl(Physics.PPM);
TextureRegion region = crabAnimation.getKeyFrame(animationTime);
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
1f, // Scale X (-1 to flip)
1f, // Scale Y
0f); // Rotation
batch.setColor(oldColor);
}
示例14: draw
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float alpha){
batch.setColor(shadowColor);
if(chatOpen)
batch.draw(skin.getRegion("white"), offsetx, chatfield.getY(), chatfield.getWidth() + 15f, chatfield.getHeight()-1);
//font.getData().down = Unit.dp.scl(-21.5f);
//font.getData().lineHeight = 22f;
//chatfield.getStyle().font.getData().setScale(Vars.fontscale);
super.draw(batch, alpha);
float spacing = chatspace;
chatfield.setVisible(chatOpen);
fieldlabel.setVisible(chatOpen);
batch.setColor(shadowColor);
float theight = offsety + spacing + getMarginBottom();
for(int i = 0; i < messagesShown && i < messages.size && i < fadetime; i ++){
layout.setText(font, messages.get(i).formattedMessage, Color.WHITE, textWidth, Align.bottomLeft, true);
theight += layout.height+textspacing;
if(i == 0) theight -= textspacing+1;
font.getCache().clear();
font.getCache().addText(messages.get(i).formattedMessage, fontoffsetx + offsetx, offsety + theight, textWidth, Align.bottomLeft, true);
if(fadetime-i < 1f && fadetime-i >= 0f){
font.getCache().setAlphas(fadetime-i);
batch.setColor(0, 0, 0, shadowColor.a*(fadetime-i));
}
batch.draw(skin.getRegion("white"), offsetx, theight-layout.height-2, textWidth + Unit.dp.scl(4f), layout.height+textspacing);
batch.setColor(shadowColor);
font.getCache().draw(batch);
}
batch.setColor(Color.WHITE);
if(fadetime > 0 && !chatOpen)
fadetime -= Timers.delta()/180f;
}
示例15: drawSplits
import com.badlogic.gdx.graphics.g2d.Batch; //導入方法依賴的package包/類
public void drawSplits(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.Line);
// left, right, top , bottom
Color guideColor = new Color(GUIDE_COLOR);
guideColor.a*=parentAlpha;
Color overColor = new Color(OVER_GUIDE_COLOR);
overColor.a*=parentAlpha;
splitPositions[0] = shift.x + getWidth() / 2f + (-texture.getRegionWidth() / 2f + splits[0]) * currZoom;
splitPositions[1] = shift.x + getWidth() / 2f + (texture.getRegionWidth() / 2f - splits[1]) * currZoom;
splitPositions[2] = shift.y + getHeight()/2f + (texture.getRegionHeight()/2 - splits[2])*currZoom;
splitPositions[3] = shift.y + getHeight() / 2f + (-texture.getRegionHeight() / 2 + splits[3]) * currZoom;
if(mouseOverSplit == 0) shapeRenderer.setColor(overColor); else shapeRenderer.setColor(guideColor);
shapeRenderer.line(getX() + splitPositions[0], getY(), getX() + splitPositions[0], getY() + getHeight());
if(mouseOverSplit == 1) shapeRenderer.setColor(overColor); else shapeRenderer.setColor(guideColor);
shapeRenderer.line(getX() + splitPositions[1], getY(), getX() + splitPositions[1], getY() + getHeight());
if(mouseOverSplit == 2) shapeRenderer.setColor(overColor); else shapeRenderer.setColor(guideColor);
shapeRenderer.line(getX(), getY() + splitPositions[2], getX() + getWidth(), getY() + splitPositions[2]);
if(mouseOverSplit == 3) shapeRenderer.setColor(overColor); else shapeRenderer.setColor(guideColor);
shapeRenderer.line(getX(), getY() + splitPositions[3], getX() + getWidth(), getY() + splitPositions[3]);
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);
}