Search in sources :

Example 46 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project Entitas-Java by Rubentxu.

the class Box method create.

@Override
public GameEntity create(Engine engine, Entitas entitas) {
    BodyBuilder bodyBuilder = engine.getManager(PhysicsManagerGDX.class).getBodyBuilder();
    float width = MathUtils.random(0.4f, 1);
    float height = MathUtils.random(0.4f, 1f);
    GameEntity entity = entitas.game.createEntity().setInteractive(true).addRigidBody(bodyBuilder.fixture(bodyBuilder.fixtureDefBuilder.boxShape(width, height).friction(0.5f).density(1f)).type(BodyDef.BodyType.DynamicBody).build()).addTextureView(new TextureRegion(assetsManager.getTexture(box2)), new Bounds(width, height), false, false, 1, 0, Color.WHITE);
    entitas.actuator.createEntity().addRadialGravityActuator(9, 5, 2).addLink(entity.getCreationIndex(), "RadialGravityActuator", true);
    return entity;
}
Also used : PhysicsManagerGDX(ilargia.egdx.impl.managers.PhysicsManagerGDX) GameEntity(ilargia.egdx.logicbricks.gen.game.GameEntity) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Bounds(ilargia.egdx.logicbricks.data.Bounds) BodyBuilder(ilargia.egdx.util.BodyBuilder)

Example 47 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project Entitas-Java by Rubentxu.

the class SplashState method initialize.

@Override
public void initialize() {
    // Input
    Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera();
    Batch batch = engine.getManager(BaseSceneManager.class).getBatch();
    BitmapFont font = engine.getManager(BaseGUIManager.class).getDefaultFont();
    systems.add(new DelaySystem(context.core)).add(new RendererSystem(context.core, engine.sr, camera, batch, font));
    Texture texture = assetsManager.getTexture(splash);
    context.core.createEntity().addTextureView("Pong", new TextureRegion(texture, 0, 0, texture.getWidth(), texture.getHeight()), new Vector2(), 0, Pong.SCREEN_HEIGHT, Pong.SCREEN_WIDTH).addDelay(3);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Batch(com.badlogic.gdx.graphics.g2d.Batch) Vector2(com.badlogic.gdx.math.Vector2) BaseSceneManager(com.ilargia.games.entitas.egdx.base.managers.BaseSceneManager) BaseGUIManager(com.ilargia.games.entitas.egdx.base.managers.BaseGUIManager) RendererSystem(com.ilargia.games.entitas.systems.RendererSystem) Camera(com.badlogic.gdx.graphics.Camera) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) Texture(com.badlogic.gdx.graphics.Texture) DelaySystem(com.ilargia.games.entitas.systems.DelaySystem)

Example 48 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project AmazingMaze by TheVirtualMachine.

the class MainMenuScreen method layoutMenu.

/**
	 * Adds buttons and the title as well as set layout for the menu.
	 *
	 * @param width The width of the screen.
	 * @param height The height of the screen.
	 */
private void layoutMenu(int width, int height) {
    table.clear();
    table.background(new TextureRegionDrawable(new TextureRegion(this.game.assets.manager.get(Assets.MENU_BACKGROUND_IMAGE, Texture.class))));
    // Add title
    table.add(menuTitle).expand();
    table.row();
    // Add buttons.
    table.add(playButton).minSize(width / 4, height / 22).maxSize(width, height / 6).prefSize(width / 2.5f, height / 10).padBottom(10);
    table.row();
    table.add(helpButton).minSize(width / 4, height / 22).maxSize(width, height / 8).prefSize(width / 2.5f, height / 10).padBottom(10);
    table.row();
    table.add(highScoresButton).minSize(width / 4, height / 22).maxSize(width, height / 8).prefSize(width / 2.5f, height / 10).padBottom(10);
    table.row();
    table.add(settingsButton).minSize(width / 4, height / 22).maxSize(width, height / 8).prefSize(width / 2.5f, height / 10).padBottom(10);
    table.row();
    table.add(creditsButton).minSize(width / 4, height / 22).maxSize(width, height / 8).prefSize(width / 2.5f, height / 10).padBottom(10);
    table.row();
    table.add(licenseButton).minSize(width / 4, height / 22).maxSize(width, height / 8).prefSize(width / 2.5f, height / 10).padBottom(10);
    table.row();
    table.add(quitButton).minSize(width / 4, height / 22).maxSize(width, height / 8).prefSize(width / 2.5f, height / 10).padBottom(10);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Texture(com.badlogic.gdx.graphics.Texture)

Example 49 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)

Example 50 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.

the class ScreenUtils method getFrameBufferTexture.

/** Returns a portion of the default framebuffer contents specified by x, y, width and height as a {@link TextureRegion} with
	 * the same dimensions. The base {@link Texture} always has {@link MathUtils#nextPowerOfTwo} dimensions and RGBA8888
	 * {@link Format}. It can be accessed via {@link TextureRegion#getTexture}. This texture is not managed and has to be reloaded
	 * manually on a context loss. If the width and height specified are larger than the framebuffer dimensions, the Texture will
	 * be padded accordingly. Pixels that fall outside of the current screen will have RGBA values of 0.
	 * 
	 * @param x the x position of the framebuffer contents to capture
	 * @param y the y position of the framebuffer contents to capture
	 * @param w the width of the framebuffer contents to capture
	 * @param h the height of the framebuffer contents to capture */
public static TextureRegion getFrameBufferTexture(int x, int y, int w, int h) {
    final int potW = MathUtils.nextPowerOfTwo(w);
    final int potH = MathUtils.nextPowerOfTwo(h);
    final Pixmap pixmap = getFrameBufferPixmap(x, y, w, h);
    final Pixmap potPixmap = new Pixmap(potW, potH, Format.RGBA8888);
    potPixmap.drawPixmap(pixmap, 0, 0);
    Texture texture = new Texture(potPixmap);
    TextureRegion textureRegion = new TextureRegion(texture, 0, h, w, -h);
    potPixmap.dispose();
    pixmap.dispose();
    return textureRegion;
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Texture(com.badlogic.gdx.graphics.Texture) Pixmap(com.badlogic.gdx.graphics.Pixmap)

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