本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.SpriteBatch.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java SpriteBatch.setColor方法的具体用法?Java SpriteBatch.setColor怎么用?Java SpriteBatch.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g2d.SpriteBatch
的用法示例。
在下文中一共展示了SpriteBatch.setColor方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void render(SpriteBatch spriteBatch) {
TextureRegion reg = null;
if (hasFeatherPowerup) {
spriteBatch.setColor(1.0f, 0.8f, 0.0f, 1.0f);
}
reg = regHead;
spriteBatch.draw(reg.getTexture(), position.x, position.y, origin.x,
origin.y, dimension.x , dimension.y, scale.x, scale.y, rotation,
reg.getRegionX(), reg.getRegionY(), reg.getRegionWidth(),
reg.getRegionHeight(), viewDirection == VIEW_DIRECTION.LEFT,
false);
spriteBatch.setColor(1, 1, 1 ,1);
}
示例2: draw
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
public void draw(SpriteBatch batch) {
// If we beat a new record, the cup color will linear interpolate to the high score color
cupColor.lerp(isNewRecord() ? Klooni.theme.highScore : Klooni.theme.currentScore, 0.05f);
batch.setColor(cupColor);
batch.draw(cupTexture, cupArea.x, cupArea.y, cupArea.width, cupArea.height);
int roundShown = MathUtils.round(shownScore);
if (roundShown != currentScore) {
shownScore = Interpolation.linear.apply(shownScore, currentScore, 0.1f);
currentScoreLabel.setText(Integer.toString(MathUtils.round(shownScore)));
}
currentScoreLabel.setColor(Klooni.theme.currentScore);
currentScoreLabel.draw(batch, 1f);
highScoreLabel.setColor(Klooni.theme.highScore);
highScoreLabel.draw(batch, 1f);
}
示例3: renderGuiExtraLives
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
private void renderGuiExtraLives(SpriteBatch batch) {
float x = cameraGUI.viewportWidth - 50 - Constants.LIVES_START * 50;
float y = -15;
for (int i = 0; i < Constants.LIVES_START; ++i) {
if (worldController.lives <= i)
batch.setColor(0.5f, 0.5f, 0.5f, 0.5f);
batch.draw(Assets.instance.bunny.head, x + i * 50, y, 50, 50, 120, 100, 0.35f, -0.35f, 0);
batch.setColor(1, 1, 1, 1);
}
}
示例4: drawMountain
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
private void drawMountain(SpriteBatch batch, float offsetX, float offsetY, float tintColor) {
TextureRegion reg = null;
batch.setColor(tintColor, tintColor, tintColor, 1);
float xRel = dimension.x * offsetX;
float yRel = dimension.y * offsetY;
//山区跨越整个关卡
int mountainLength = 0;
mountainLength += MathUtils.ceil(length / (2 * dimension.x));
mountainLength += MathUtils.ceil(0.5f + offsetX);
for (int i = 0; i < mountainLength; i++) {
// mountain left
reg = regMountainLeft;
batch.draw(reg.getTexture(), origin.x + xRel, position.y + origin.y
+ yRel, origin.x, origin.y, dimension.x, dimension.y,
scale.x, scale.y, rotation, reg.getRegionX(),
reg.getRegionY(), reg.getRegionWidth(),
reg.getRegionHeight(), false, false);
xRel += dimension.x;
// mountain right
reg = regMountainRight;
batch.draw(reg.getTexture(), origin.x + xRel, position.y + origin.y
+ yRel, origin.x, origin.y, dimension.x, dimension.y,
scale.x, scale.y, rotation, reg.getRegionX(),
reg.getRegionY(), reg.getRegionWidth(),
reg.getRegionHeight(), false, false);
xRel += dimension.x;
}
// reset color to white
batch.setColor(1, 1, 1, 1);
}
示例5: renderGL2
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void renderGL2(float gameTime)
{
GLCommon gl = Gdx.gl;
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
SpriteBatch batch = getSpriteBatch();
viewMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.setProjectionMatrix(viewMatrix);
batch.begin();
batch.disableBlending();
batch.setColor(Color.WHITE);
//begin render background
renderBackground(gameTime);
batch.enableBlending();
batch.end();
gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glEnable(GL10.GL_CULL_FACE);
camera.update();
for(IDrawable3D obj : collection)
if(obj.isVisible())
{
obj.renderGL2(gameTime);
}
gl.glDisable(GL10.GL_CULL_FACE);
gl.glDisable(GL10.GL_DEPTH_TEST);
batch.setProjectionMatrix(viewMatrix);
batch.begin();
//begin render foreground
renderForeground(gameTime);
//batch.enableBlending();
//batch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
batch.end();
}
示例6: drawLayer0
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void drawLayer0(GameTime time, SpriteBatch batch) {
if (hovered) {
batch.setColor(hoverColor);
}
batch.draw(this.texture, getX(), getY(), getWidth(), getHeight());
batch.setColor(1, 1, 1, 1);
// draw key text
font.draw(batch, key.toUpperCase(), getX() + getWidth() - (textPaddingX * key.length()), getY() + textPaddingY);
}
示例7: fillRectangle
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
public static void fillRectangle(SpriteBatch batch, float x, float y, float width, float height, Color color) {
initTextureIfAbsent();
// backup color
Color backupColor = batch.getColor();
// set rectangle color
batch.setColor(color);
batch.draw(textureRegion, x, y, width, height);
// reset color
batch.setColor(backupColor);
}
示例8: renderObjects
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
private void renderObjects(SpriteBatch batch) {
for(int i = -3; i <= 3; i++) {
for(int j = -3; j <= 3; j++) {
int ia = Math.abs(i);
int ja = Math.abs(j);
if(ia == 2 && ja == 2) {
batch.setColor(1, 1, 1, 0.25f);
} else if((ia == 2 || ja == 2) && (ia != 3) && (ja != 3)) {
batch.setColor(1, 1, 1, 0.5f);
}
else if((ia == 3 && ja < 2) || (ja == 3 && ia < 2)){
batch.setColor(1, 1, 1, 0.25f);
}
else if(ia < 2 && ja < 2){
batch.setColor(1, 1, 1, 1);
}
else{
batch.setColor(1,1,1,0);
}
int x = i + player.getTileX();
int y = j + player.getTileY();
if(x >= 0 && x < width && y >= 0 && y < height)
if(objects[x][y] != null)
objects[x][y].render(batch);
}
}
batch.setColor(1, 1, 1, 1);
}
示例9: render
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void render(SpriteBatch batch)
{
float currentFade = (totalFadingTime - currentFadingTime)/totalFadingTime;
batch.setColor(1.0f, 1.0f, 1.0f, currentFade);
batch.draw(texture, x, y, bounds.width, bounds.height);
batch.setColor(1.0f, 1.0f, 1.0f, 1.0f);
}
示例10: render
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void render(SpriteBatch batch)
{
batch.setColor(1.0f, 1.0f, 1.0f, 0.5f);
batch.draw(highlightingGraphic, gameObject.getX(), gameObject.getY(), gameObject.getWidth(),
gameObject.getHeight());
batch.setColor(1.0f, 1.0f, 1.0f, 1.0f);
}
示例11: drawToBuffer
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
/**
* Draws the given gradient {@link Texture} to the given {@link FrameBuffer}, using the given {@link Color} with the given percent.
* <p>
* This is achieved via a gradient shader.
*
* @param buffer the {@link FrameBuffer} to be drawn to
* @param color the {@link Color} which should be drawn
* @param gradient the gradient texture which should be drawn
* @param perc the percent the gradient texture should be drawn
* @param shaderBatch the {@link SpriteBatch} to use
* @param shader the {@link ShaderProgram} to use
* @param projection projection matrix for pixel perfect rendering
*/
private static void drawToBuffer(FrameBuffer buffer, Color color, Texture gradient, float perc, SpriteBatch shaderBatch, ShaderProgram shader, Matrix4 projection) {
buffer.begin();
AL.graphics.getGL20().glClearColor(0, 0, 0, 0);
AL.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);
shaderBatch.setProjectionMatrix(projection);
shaderBatch.begin();
shaderBatch.setColor(color);
shader.setUniformf("u_gradient", perc);
shaderBatch.draw(gradient, -buffer.getWidth() / 2, -buffer.getHeight() / 2);
shaderBatch.end();
buffer.end();
}
示例12: 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;
}
示例13: draw
import com.badlogic.gdx.graphics.g2d.SpriteBatch; //导入方法依赖的package包/类
@Override
public void draw(SpriteBatch spriteBatch, float delta) {
spriteBatch.setColor(1.0f, 1.0f, 1.0f, life / LIFE_MAX);
spriteBatch.draw(region, 0.0f, 0.0f, 0.0f, 0.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 1.0f, 1.0f, 0.0f);
spriteBatch.setColor(Color.WHITE);
}