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;
}
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);
}
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);
}
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;
}
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;
}
Aggregations