use of com.badlogic.gdx.graphics.g2d.TextureRegion in project Alkahest-Coffee by AlkahestDev.
the class GifDecoder method getAnimation.
public Animation getAnimation(Animation.PlayMode playType) {
int nrFrames = getFrameCount();
Pixmap frame = getFrame(0);
int width = frame.getWidth();
int height = frame.getHeight();
int vzones = (int) Math.sqrt((double) nrFrames);
int hzones = vzones;
while (vzones * hzones < nrFrames) vzones++;
int v, h;
Pixmap target = new Pixmap(width * hzones, height * vzones, Pixmap.Format.RGBA8888);
for (h = 0; h < hzones; h++) {
for (v = 0; v < vzones; v++) {
int frameID = v + h * vzones;
if (frameID < nrFrames) {
frame = getFrame(frameID);
target.drawPixmap(frame, h * width, v * height);
}
}
}
Texture texture = new Texture(target);
Array<TextureRegion> texReg = new Array<TextureRegion>();
for (h = 0; h < hzones; h++) {
for (v = 0; v < vzones; v++) {
int frameID = v + h * vzones;
if (frameID < nrFrames) {
TextureRegion tr = new TextureRegion(texture, h * width, v * height, width, height);
texReg.add(tr);
}
}
}
float frameDuration = (float) getDelay(0);
// convert milliseconds into seconds
frameDuration /= 1000;
return new Animation<TextureRegion>(frameDuration, texReg, playType);
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion in project Alkahest-Coffee by AlkahestDev.
the class MainGame method setupLoadingMenu.
public void setupLoadingMenu() {
int numFrames = 39;
for (int i = 0; i < numFrames; i++) {
loadingMenu.addBackground(new TextureRegion(new Texture(Gdx.files.internal(String.format("loading/loadingKnight/loadingKnight%d.png", i)))));
}
loadingMenu.setFrameRate(25);
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion in project Alkahest-Coffee by AlkahestDev.
the class ServerBrowser method addBackButton.
private void addBackButton() {
MenuTools.Button bt = new MenuTools.Button(0, Gdx.graphics.getHeight() - 65, 60, 60);
bt.setCallback(new MenuTools.OnClick() {
@Override
public void action() {
MainGame.state = GameState.State.MAINMENU;
}
});
bt.setPressedTexture(new TextureRegion((Texture) getManager().get("R1.png")));
bt.setUnpressedTexture(new TextureRegion((Texture) getManager().get("R2.png")));
super.addButton(bt);
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion in project Alkahest-Coffee by AlkahestDev.
the class ServerBrowser method init.
/**
* Initializes the ServerBrowser
*/
public void init() {
//super.init();
super.setBackground(new TextureRegion((Texture) super.getManager().get("tuzki.png")));
float serverListHeight = 3000;
serverList = new ServerBrowserList(Gdx.graphics.getWidth() - 400, Gdx.graphics.getHeight() - serverListHeight, 400, serverListHeight, super.getFonts(), this.getManager());
super.addMenuBox(serverList);
addRefreshButton();
addBackButton();
MenuTools.TextField directConnect = new MenuTools.TextField(5, 5, 400, 40);
directConnect.setEnterAction(new MenuTools.OnEnter() {
@Override
public void action(String sIn) {
MainGame.client.connectServerPlay(sIn);
MainGame.state = GameState.State.CONNECTINGTOSERVER;
}
});
super.addTextField(directConnect);
}
use of com.badlogic.gdx.graphics.g2d.TextureRegion in project Catacomb-Snatch by Catacomb-Snatch.
the class Art method loadResources.
/**
* Loads all the artwork
*
* @return True on success, otherwise false
*/
public static boolean loadResources() {
try {
// Load interface
skin = new Skin(Gdx.files.internal("art/interface.skin"), new TextureAtlas("art/interface.atlas"));
// Load backgrounds
pyramid = new TextureRegion(load("screen/pyramid.png"));
// Load characters
lordLard = cut("player/lord_lard.png", 32, 32);
// Load tiles
tiles_floor = cut("tiles/floor.png", 32, 32)[0];
tiles_sand = cut("tiles/sand.png", 32, 32)[0];
tiles_walls = cut("tiles/walls.png", 32, 56)[0];
tiles_shadows = cut("tiles/shadows.png", 32, 32)[0];
tiles_hole = cut("tiles/hole.png", 32, 32)[0];
// Load extras
logo = new TextureRegion(load("logo.png"));
return true;
} catch (Exception e) {
Gdx.app.error(TAG, "Something went wrong while loading a resource: ", e);
}
return false;
}
Aggregations