Add a new underwater theme
This commit is contained in:
parent
d34a566af3
commit
4e5c4fd453
9 changed files with 115 additions and 149 deletions
|
@ -38,7 +38,7 @@ public class Theme {
|
|||
|
||||
public static Skin skin;
|
||||
|
||||
public NinePatch cellPatch;
|
||||
public Texture cellTexture;
|
||||
|
||||
// Save the button styles so the changes here get reflected
|
||||
private ImageButton.ImageButtonStyle[] buttonStyles;
|
||||
|
@ -153,8 +153,7 @@ public class Theme {
|
|||
}
|
||||
|
||||
String cellTextureFile = json.getString("cell_texture");
|
||||
cellPatch = new NinePatch(new Texture(
|
||||
Gdx.files.internal("ui/cells/"+cellTextureFile)), 4, 4, 4, 4);
|
||||
cellTexture = new Texture(Gdx.files.internal("ui/cells/"+cellTextureFile));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,12 @@ public class ThemeCard extends Actor {
|
|||
|
||||
public float cellSize;
|
||||
|
||||
private final static int colorsUsed[][] = {
|
||||
{0, 7, 7},
|
||||
{8, 7, 3},
|
||||
{8, 8, 3}
|
||||
};
|
||||
|
||||
//endregion
|
||||
|
||||
//region Constructor
|
||||
|
@ -64,21 +70,14 @@ public class ThemeCard extends Actor {
|
|||
|
||||
batch.setColor(theme.background);
|
||||
batch.draw(background, x, y, getWidth(), getHeight());
|
||||
// Do not draw on the borders (0,0 offset to add some padding), colors used:
|
||||
// 0 7 7
|
||||
// 8 7 3
|
||||
// 8 8 3
|
||||
Cell.draw(theme.getCellColor(0), batch, x + cellSize, y + cellSize, cellSize);
|
||||
Cell.draw(theme.getCellColor(7), batch, x + cellSize * 2, y + cellSize, cellSize);
|
||||
Cell.draw(theme.getCellColor(7), batch, x + cellSize * 3, y + cellSize, cellSize);
|
||||
|
||||
Cell.draw(theme.getCellColor(8), batch, x + cellSize, y + cellSize * 2, cellSize);
|
||||
Cell.draw(theme.getCellColor(7), batch, x + cellSize * 2, y + cellSize * 2, cellSize);
|
||||
Cell.draw(theme.getCellColor(8), batch, x + cellSize * 3, y + cellSize * 2, cellSize);
|
||||
|
||||
Cell.draw(theme.getCellColor(8), batch, x + cellSize, y + cellSize * 3, cellSize);
|
||||
Cell.draw(theme.getCellColor(8), batch, x + cellSize * 2, y + cellSize * 3, cellSize);
|
||||
Cell.draw(theme.getCellColor(3), batch, x + cellSize * 3, y + cellSize * 3, cellSize);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
nameLabel.setBounds(x + nameBounds.x, y + nameBounds.y, nameBounds.width, nameBounds.height);
|
||||
nameLabel.draw(batch, parentAlpha);
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.github.lonamiwebs.klooni.game;
|
|||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
|
@ -105,11 +106,18 @@ public class Cell implements BinSerializable {
|
|||
|
||||
//region Static methods
|
||||
|
||||
// TODO Use skin atlas
|
||||
public static void draw(Color color, Batch batch,
|
||||
float x, float y, float size) {
|
||||
// Default texture (don't call overloaded version to avoid overhead)
|
||||
public static void draw(final Color color, final Batch batch,
|
||||
final float x, final float y, final float size) {
|
||||
batch.setColor(color);
|
||||
Klooni.theme.cellPatch.draw(batch, x, y, size, size);
|
||||
batch.draw(Klooni.theme.cellTexture, x, y, size, size);
|
||||
}
|
||||
|
||||
// Custom texture
|
||||
public static void draw(final Texture texture, final Color color, final Batch batch,
|
||||
final float x, final float y, final float size) {
|
||||
batch.setColor(color);
|
||||
batch.draw(texture, x, y, size, size);
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue