Example usage for com.badlogic.gdx.graphics.g2d TextureRegion TextureRegion

List of usage examples for com.badlogic.gdx.graphics.g2d TextureRegion TextureRegion

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d TextureRegion TextureRegion.

Prototype

public TextureRegion(TextureRegion region, int x, int y, int width, int height) 

Source Link

Document

Constructs a region with the same texture as the specified region and sets the coordinates relative to the specified region.

Usage

From source file:app.badlogicgames.superjumper.Assets.java

License:Apache License

public static void load() {
    background = loadTexture(prefix + "background.png");
    backgroundRegion = new TextureRegion(background, 0, 0, 320, 480);

    items = loadTexture(prefix + "items.png");
    multiplayer = loadTexture(prefix + "multiplayer.png");
    // DATest//from  ww w  .j  a  v a2  s .c o  m
    // enemyBob = loadTexture(prefix + "monster2.png");
    enemyBob1 = loadTexture(prefix + "monster2.png");
    enemyBob2 = loadTexture(prefix + "monster3.png");

    mainMenu = new TextureRegion(items, 0, 224, 300, 110);
    pauseMenu = new TextureRegion(items, 224, 128, 192, 96);
    ready = new TextureRegion(items, 320, 224, 192, 32);
    gameOver = new TextureRegion(items, 352, 256, 160, 96);
    highScoresRegion = new TextureRegion(Assets.items, 0, 257, 300, 110 / 3);
    logo = new TextureRegion(items, 0, 352, 274, 142);
    soundOff = new TextureRegion(items, 0, 0, 64, 64);
    soundOn = new TextureRegion(items, 64, 0, 64, 64);
    arrow = new TextureRegion(items, 0, 64, 64, 64);
    pause = new TextureRegion(items, 64, 64, 64, 64);

    spring = new TextureRegion(items, 128, 0, 32, 32);
    castle = new TextureRegion(items, 128, 64, 64, 64);
    coinAnim = new Animation(0.2f, new TextureRegion(items, 128, 32, 32, 32),
            new TextureRegion(items, 160, 32, 32, 32), new TextureRegion(items, 192, 32, 32, 32),
            new TextureRegion(items, 160, 32, 32, 32));
    bobJump = new Animation(0.2f, new TextureRegion(items, 0, 128, 32, 32),
            new TextureRegion(items, 32, 128, 32, 32));
    bobFall = new Animation(0.2f, new TextureRegion(items, 64, 128, 32, 32),
            new TextureRegion(items, 96, 128, 32, 32));
    bobHit = new TextureRegion(items, 128, 128, 32, 32);
    squirrelFly = new Animation(0.2f, new TextureRegion(items, 0, 160, 32, 32),
            new TextureRegion(items, 32, 160, 32, 32));
    platform = new TextureRegion(items, 64, 160, 64, 16);
    brakingPlatform = new Animation(0.2f, new TextureRegion(items, 64, 160, 64, 16),
            new TextureRegion(items, 64, 176, 64, 16), new TextureRegion(items, 64, 192, 64, 16),
            new TextureRegion(items, 64, 208, 64, 16));

    font = new BitmapFont(Gdx.files.internal(prefix + "font.fnt"), Gdx.files.internal(prefix + "font.png"),
            false);

    music = Gdx.audio.newMusic(Gdx.files.internal(prefix + "music.mp3"));
    music.setLooping(true);
    music.setVolume(0.5f);
    if (Settings.soundEnabled)
        music.play();
    jumpSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "jump.wav"));
    highJumpSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "highjump.wav"));
    hitSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "hit.wav"));
    coinSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "coin.wav"));
    clickSound = Gdx.audio.newSound(Gdx.files.internal(prefix + "click.wav"));

    FileHandle file = Gdx.files.internal(prefix + "platform.data");
    platformDataString = file.readString();
}

From source file:app.badlogicgames.superjumper.HelpScreen.java

License:Apache License

public HelpScreen(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    nextBounds = new Rectangle(320 - 64, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    helpImage = Assets.loadTexture("data/help1.png");
    helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}

From source file:app.badlogicgames.superjumper.HelpScreen2.java

License:Apache License

public HelpScreen2(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    nextBounds = new Rectangle(320 - 64, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    helpImage = Assets.loadTexture("data/help2.png");
    helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}

From source file:app.badlogicgames.superjumper.HelpScreen3.java

License:Apache License

public HelpScreen3(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    nextBounds = new Rectangle(320 - 64, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    helpImage = Assets.loadTexture("data/help3.png");
    helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}

From source file:app.badlogicgames.superjumper.HelpScreen4.java

License:Apache License

public HelpScreen4(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    nextBounds = new Rectangle(320 - 64, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    helpImage = Assets.loadTexture("data/help4.png");
    helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}

From source file:app.badlogicgames.superjumper.HelpScreen5.java

License:Apache License

public HelpScreen5(Game game) {
    this.game = game;

    guiCam = new OrthographicCamera(320, 480);
    guiCam.position.set(320 / 2, 480 / 2, 0);
    nextBounds = new Rectangle(320 - 64, 0, 64, 64);
    touchPoint = new Vector3();
    batcher = new SpriteBatch();
    helpImage = Assets.loadTexture("data/help5.png");
    helpRegion = new TextureRegion(helpImage, 0, 0, 320, 480);
}

From source file:awakening.view.menu.MapSelection.java

License:Apache License

/**
 * Constructor/*from  w  ww  . j a va2  s .co m*/
 * 
 * @param game Tower Awakening's Game
 * @param sound Main menu's music
 * @param effect Button's effect
 */
public MapSelection(final TAGame game, Music sound, final Sound effect) {
    this.game = game;
    this.sound = sound;
    this.effect = effect;
    stage = new Stage();

    try {
        File monsterDirectory = Gdx.files.internal("Field").file();
        for (File ft : monsterDirectory.listFiles()) {
            if (ft.isFile())
                if (ft.getName().endsWith("mta")) {
                    Field newMap = Field.loadTower(ft);
                    if (newMap != null)
                        mapListes.add(newMap);
                }
        }

        if (game.getLanguage().equals("ENGLISH")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]);
        } else if (game.getLanguage().equals("FRENCH")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]);
        } else if (game.getLanguage().equals("ITALIAN")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]);
        } else {
            language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]);
        }
    } catch (java.util.MissingResourceException e) {
        System.out.println("yolo");
    }

    ///Viewport
    camera = new OrthographicCamera();
    view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera);

    ///Background
    background = new Texture(Gdx.files.internal("img/menu/Background-2.png"));
    batch = new SpriteBatch();

    ///Skin
    skin = new Skin(Gdx.files.internal("uiskin.json"));

    ///Title
    title = new Label(language.getString("label_map_selection"), skin);

    ///Widgets Background
    widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/window_selection.png")));
    widgetsBackground.setSize(Gdx.app.getGraphics().getWidth() - Gdx.app.getGraphics().getWidth() / 8,
            Gdx.app.getGraphics().getHeight() - Gdx.app.getGraphics().getHeight() / 8);

    ///Back Button
    btnBack = new TextButton(language.getString("button_back"), skin);
    btnJeu = new TextButton(language.getString("button_game"), skin);

    ///Next Button
    Texture t1 = new Texture(Gdx.files.internal("img/widget/arrow_hover_right.png"));
    Texture t2 = new Texture(Gdx.files.internal("img/widget/arrow_right.png"));
    ImageButtonStyle style1 = new ImageButtonStyle(
            new TextureRegionDrawable(new TextureRegion(t1, 0, 0, t1.getWidth(), t1.getHeight())),
            new TextureRegionDrawable(new TextureRegion(t2, 0, 0, t2.getWidth(), t2.getHeight())),
            new TextureRegionDrawable(new TextureRegion(t1, 0, 0, t1.getWidth(), t1.getHeight())),
            new TextureRegionDrawable(new TextureRegion(t2, 0, 0, t2.getWidth(), t2.getHeight())),
            new TextureRegionDrawable(new TextureRegion(t1, 0, 0, t1.getWidth(), t1.getHeight())),
            new TextureRegionDrawable(new TextureRegion(t2, 0, 0, t2.getWidth(), t2.getHeight())));
    btnNext = new ImageButton(style1);

    ///Previous Button
    Texture t3 = new Texture(Gdx.files.internal("img/widget/arrow_hover_left.png"));
    Texture t4 = new Texture(Gdx.files.internal("img/widget/arrow_left.png"));
    ImageButtonStyle style2 = new ImageButtonStyle(
            new TextureRegionDrawable(new TextureRegion(t3, 0, 0, t3.getWidth(), t3.getHeight())),
            new TextureRegionDrawable(new TextureRegion(t4, 0, 0, t4.getWidth(), t4.getHeight())),
            new TextureRegionDrawable(new TextureRegion(t3, 0, 0, t3.getWidth(), t3.getHeight())),
            new TextureRegionDrawable(new TextureRegion(t4, 0, 0, t4.getWidth(), t4.getHeight())),
            new TextureRegionDrawable(new TextureRegion(t3, 0, 0, t3.getWidth(), t3.getHeight())),
            new TextureRegionDrawable(new TextureRegion(t4, 0, 0, t4.getWidth(), t4.getHeight())));

    btnPrevious = new ImageButton(style2);

    maps = new ArrayList<BoutonShop>();

}

From source file:br.unb.bomberman.ui.screens.Assets.java

License:Apache License

public static void load() {
    background = loadTexture("map_tiles.png");
    backgroundGround = new TextureRegion(background, 0, 0, 32, 32);
    backgroundSBlock = new TextureRegion(background, 64, 0, 32, 32);
    backgroundHBlock = new TextureRegion(background, 96, 0, 32, 32);

    walking = loadTexture("walking.png");
    walkingFront = new TextureRegion(walking, 8 * 218 / 12, 0, 218 / 12, 22);

    bombs = loadTexture("bomb_anim.png");

    bomb = new Animation(0.8f, new TextureRegion(bombs, 0, 0, 32, 32), new TextureRegion(bombs, 32, 0, 32, 32),
            new TextureRegion(bombs, 64, 0, 32, 32), new TextureRegion(bombs, 32, 0, 32, 32));

    explosion = loadTexture("explosion.png");
    explosionCenter = new TextureRegion(explosion, 4 * 32, 0, 32, 32);

    items = loadTexture("data/items.png");
    mainMenu = new TextureRegion(items, 0, 224, 300, 110);
    pauseMenu = new TextureRegion(items, 224, 128, 192, 96);
    ready = new TextureRegion(items, 320, 224, 192, 32);
    gameOver = new TextureRegion(items, 352, 256, 160, 96);
    highScoresRegion = new TextureRegion(Assets.items, 0, 257, 300, 110 / 3);
    logo = new TextureRegion(items, 0, 352, 274, 142);
    soundOff = new TextureRegion(items, 0, 0, 64, 64);
    soundOn = new TextureRegion(items, 64, 0, 64, 64);
    arrow = new TextureRegion(items, 0, 64, 64, 64);
    pause = new TextureRegion(items, 64, 64, 64, 64);

    spring = new TextureRegion(items, 128, 0, 32, 32);
    castle = new TextureRegion(items, 128, 64, 64, 64);
    coinAnim = new Animation(0.2f, new TextureRegion(items, 128, 32, 32, 32),
            new TextureRegion(items, 160, 32, 32, 32), new TextureRegion(items, 192, 32, 32, 32),
            new TextureRegion(items, 160, 32, 32, 32));
    bobJump = new Animation(0.2f, new TextureRegion(items, 0, 128, 32, 32),
            new TextureRegion(items, 32, 128, 32, 32));
    bobFall = new Animation(0.2f, new TextureRegion(items, 64, 128, 32, 32),
            new TextureRegion(items, 96, 128, 32, 32));
    bobHit = new Animation(0.2f, new TextureRegion(items, 128, 128, 32, 32));
    squirrelFly = new Animation(0.2f, new TextureRegion(items, 0, 160, 32, 32),
            new TextureRegion(items, 32, 160, 32, 32));
    platform = new Animation(0.2f, new TextureRegion(items, 64, 160, 64, 16));
    breakingPlatform = new Animation(0.2f, new TextureRegion(items, 64, 160, 64, 16),
            new TextureRegion(items, 64, 176, 64, 16), new TextureRegion(items, 64, 192, 64, 16),
            new TextureRegion(items, 64, 208, 64, 16));

    font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);

    music = Gdx.audio.newMusic(Gdx.files.internal("data/music.mp3"));
    music.setLooping(true);/*from  ww  w.j  av  a 2 s  .c om*/
    music.setVolume(Settings.soundVolume);
    if (Settings.soundEnabled)
        music.play();
    jumpSound = Gdx.audio.newSound(Gdx.files.internal("data/jump.wav"));
    highJumpSound = Gdx.audio.newSound(Gdx.files.internal("data/highjump.wav"));
    hitSound = Gdx.audio.newSound(Gdx.files.internal("data/hit.wav"));
    coinSound = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav"));
    clickSound = Gdx.audio.newSound(Gdx.files.internal("data/click.wav"));

    coinAnim.setPlayMode(PlayMode.LOOP);
    bobJump.setPlayMode(PlayMode.LOOP);
    bobFall.setPlayMode(PlayMode.LOOP);
    bobHit.setPlayMode(PlayMode.LOOP);
    squirrelFly.setPlayMode(PlayMode.LOOP);
    platform.setPlayMode(PlayMode.LOOP);

}

From source file:ca.viaware.game.assets.Tileset.java

License:Open Source License

public void addRegion(String name, int x, int y, int width, int height) {
    regions.put(name, new TextureRegion(getTexture(), x, y, width, height));
}

From source file:ch.coldpixel.alpha.level.TextureLoader.java

public TextureLoader() {
    //Background/*from  ww  w  .  j  a  v  a 2  s  .c o m*/
    backgroundTexture = new Texture(Gdx.files.internal("Graphics/Background/BackgroundRegion.png"));
    cloud = new TextureRegion(backgroundTexture, 0, 32, 16, 62);
    ground = new TextureRegion(backgroundTexture, 0, 16, 16, 16);
    groundTop = new TextureRegion(backgroundTexture, 0, 0, 16, 16);
    //Items
    itemList = new Texture(Gdx.files.internal("Graphics/Items/itemList.png"));
    sword = new TextureRegion(itemList, 0, 0, 24, 24);
}