Search in sources :

Example 51 with TextureRegion

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);
}
Also used : Array(com.badlogic.gdx.utils.Array) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Animation(com.badlogic.gdx.graphics.g2d.Animation) Texture(com.badlogic.gdx.graphics.Texture) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 52 with TextureRegion

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);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion)

Example 53 with TextureRegion

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);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) MenuTools(me.dumfing.gdxtools.MenuTools) Texture(com.badlogic.gdx.graphics.Texture)

Example 54 with TextureRegion

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);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) MenuTools(me.dumfing.gdxtools.MenuTools) Texture(com.badlogic.gdx.graphics.Texture)

Example 55 with TextureRegion

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;
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Aggregations

TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)115 Texture (com.badlogic.gdx.graphics.Texture)57 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)22 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)18 Stage (com.badlogic.gdx.scenes.scene2d.Stage)18 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)13 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)13 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)11 NinePatch (com.badlogic.gdx.graphics.g2d.NinePatch)11 AtlasSprite (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite)11 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)10 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)10 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)10 Pixmap (com.badlogic.gdx.graphics.Pixmap)8 Color (com.badlogic.gdx.graphics.Color)7 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)7 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)7 Test (org.junit.Test)7 FileHandle (com.badlogic.gdx.files.FileHandle)6 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)6