Java Code Examples for com.badlogic.gdx.graphics.g2d.TextureAtlas#AtlasRegion

The following examples show how to use com.badlogic.gdx.graphics.g2d.TextureAtlas#AtlasRegion . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommonPower.java    From StS-DefaultModBase with MIT License 6 votes vote down vote up
public CommonPower(final AbstractCreature owner, final AbstractCreature source, final int amount) {
    name = NAME;
    ID = POWER_ID;

    this.owner = owner;
    this.amount = amount;
    this.source = source;

    type = PowerType.BUFF;
    isTurnBased = false;

    // We load those txtures here.
    this.region128 = new TextureAtlas.AtlasRegion(tex84, 0, 0, 84, 84);
    this.region48 = new TextureAtlas.AtlasRegion(tex32, 0, 0, 32, 32);

    updateDescription();
}
 
Example 2
Source File: RenderUtils.java    From jorbs-spire-mod with MIT License 6 votes vote down vote up
public static void renderAtlasRegionCenteredAt(SpriteBatch sb, TextureAtlas.AtlasRegion atlasRegion, float x, float y, float offsetX, float offsetY, float scale, Color color, float rotation) {
    sb.setColor(color);
    float offsetXDrawn = offsetX * scale * MathUtils.cosDeg(rotation) + offsetY * scale * MathUtils.sinDeg(rotation);
    float offsetYDrawn = offsetX * scale * MathUtils.sinDeg(rotation) - offsetY * scale * MathUtils.cosDeg(rotation);
    sb.draw(
            atlasRegion,
            x + atlasRegion.offsetX - (float) atlasRegion.packedWidth / 2.0F + offsetXDrawn,
            y + atlasRegion.offsetY - (float) atlasRegion.packedHeight / 2.0F + offsetYDrawn,
            (float) atlasRegion.packedWidth / 2.0F - atlasRegion.offsetX,
            (float) atlasRegion.packedHeight / 2.0F - atlasRegion.offsetY,
            (float) atlasRegion.packedWidth,
            (float) atlasRegion.packedHeight,
            scale,
            scale,
            rotation);
}
 
Example 3
Source File: StaticMemoryInfo.java    From jorbs-spire-mod with MIT License 6 votes vote down vote up
private <T extends AbstractMemory> StaticMemoryInfo(Class<T> memoryClass) {
    CLASS = memoryClass;
    ID = JorbsMod.makeID(memoryClass.getSimpleName());
    PowerStrings powerStrings = CardCrawlGame.languagePack.getPowerStrings(ID);
    NAME = powerStrings.NAME;
    DESCRIPTIONS = powerStrings.DESCRIPTIONS;

    String imageFilenamePrefix = memoryClass.getSimpleName().replace("Memory","");
    CLARITY_TEXTURE_84 = TextureLoader.getTexture(makeMemoryPath("c" + imageFilenamePrefix + "_84.png"));
    CLARITY_TEXTURE_48 = TextureLoader.getTexture(makeMemoryPath("c" + imageFilenamePrefix + "_48.png"));
    EMPTY_TEXTURE_84 = TextureLoader.getTexture(makeMemoryPath("e" + imageFilenamePrefix + "_84.png"));
    EMPTY_TEXTURE_48 = TextureLoader.getTexture(makeMemoryPath("e" + imageFilenamePrefix + "_48.png"));
    REMEMBER_TEXTURE_84 = TextureLoader.getTexture(makeMemoryPath("r" + imageFilenamePrefix + "_84.png"));
    REMEMBER_TEXTURE_48 = TextureLoader.getTexture(makeMemoryPath("r" + imageFilenamePrefix + "_48.png"));

    CLARITY_IMG_84 = new TextureAtlas.AtlasRegion(CLARITY_TEXTURE_84, 0, 0, 84, 84);
    CLARITY_IMG_48 = new TextureAtlas.AtlasRegion(CLARITY_TEXTURE_48, 0, 0, 48, 48);
    EMPTY_IMG_84 = new TextureAtlas.AtlasRegion(EMPTY_TEXTURE_84, 0, 0, 84, 84);
    EMPTY_IMG_48 = new TextureAtlas.AtlasRegion(EMPTY_TEXTURE_48, 0, 0, 48, 48);
    REMEMBER_IMG_84 = new TextureAtlas.AtlasRegion(REMEMBER_TEXTURE_84, 0, 0, 84, 84);
    REMEMBER_IMG_48 = new TextureAtlas.AtlasRegion(REMEMBER_TEXTURE_48, 0, 0, 48, 48);
}
 
Example 4
Source File: TalosAssetProvider.java    From talos with Apache License 2.0 6 votes vote down vote up
private TextureRegion findRegionOrLoad (String assetName) {
	final TextureAtlas.AtlasRegion region = atlas.findRegion(assetName);
	if (region == null) {
		//Look in all paths, and hopefully load the requested asset, or fail (crash)
		//if has extension remove it
		if(assetName.contains(".")) {
			assetName = assetName.substring(0, assetName.lastIndexOf("."));
		}
		FileHandle file = findFile(assetName);
		if (file == null || !file.exists()) {
			//throw new GdxRuntimeException("No region found for: " + assetName + " from provider");
			// try the tracker first
			file = TalosMain.Instance().FileTracker().findFileByName(assetName + ".png");
			if(file == null) {
				return null;
			}
		}
		Texture texture = new Texture(file);
		TextureRegion textureRegion = new TextureRegion(texture);
		atlas.addRegion(assetName, textureRegion);
		return textureRegion;
	}
	return region;
}
 
Example 5
Source File: TalosAssetProvider.java    From talos with Apache License 2.0 6 votes vote down vote up
public Sprite replaceRegion (FileHandle handle) {
	Texture texture = new Texture(handle);
	final Sprite textureRegion = new Sprite(texture);

	final Array<TextureAtlas.AtlasRegion> regions = atlas.getRegions();

	for (int i = 0; i < regions.size; i++) {
		if (regions.get(i).name.equalsIgnoreCase(handle.nameWithoutExtension())) {
			regions.removeIndex(i);
			break;
		}
	}

	atlas.addRegion(handle.nameWithoutExtension(), textureRegion);

	return textureRegion;
}
 
Example 6
Source File: GameSceneState.java    From Entitas-Java with MIT License 5 votes vote down vote up
@Override
public void initialize() {
    atlas = assetsManager.getTextureAtlas(SPRITE_ATLAS);
    Array<TextureAtlas.AtlasRegion> heroWalking = atlas.findRegions("Andando");
    Array<TextureAtlas.AtlasRegion> heroJump = atlas.findRegions("Saltando");
    Array<TextureAtlas.AtlasRegion> heroFall = atlas.findRegions("Cayendo");
    Array<TextureAtlas.AtlasRegion> heroIdle = atlas.findRegions("Parado");


    Animation walking = new Animation(RUNNING_FRAME_DURATION, heroWalking, Animation.PlayMode.LOOP);
    Animation jump = new Animation(RUNNING_FRAME_DURATION * 7, heroJump, Animation.PlayMode.NORMAL);
    Animation fall = new Animation(RUNNING_FRAME_DURATION * 5, heroFall, Animation.PlayMode.NORMAL);
    Animation idle = new Animation(RUNNING_FRAME_DURATION * 4, heroIdle, Animation.PlayMode.LOOP);


    Map animationHero = Collections.createMap(String.class, Animation.class);
    animationHero.put("WALKING", walking);
    animationHero.put("JUMPING", jump);
    animationHero.put("FALL", fall);
    animationHero.put("HURT", fall);
    animationHero.put("IDLE", idle);
    animationHero.put("HIT", fall);


    Body body = bodyBuilder.fixture(new FixtureDefBuilder()
            .boxShape(0.5f, 0.5f))
            .type(BodyDef.BodyType.KinematicBody)
            .build();


    systems.add(new InputsControllerSystem(entitas.input, guiFactory))
            .add(new AnimationSystem(entitas))
            .add(new TextureRendererSystem(entitas, engine.batch));


    entitas.game.getPlayerEntity()
            .addTextureView(null,new Bounds(0.8f,1.2f),false,false,1,1, Color.WHITE)
            .addAnimations(animationHero, walking, 0.02f)
            .addRigidBody(body);
}
 
Example 7
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addBottomRightCornerTransition(String name, int x, int y, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("transitions/" + name + "-corner").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    layer.addActor(image);
    image.setRotation(180);
    image.setPosition((x + 1) * CELL_SIZE, (y + 1) * CELL_SIZE);
    return image;
}
 
Example 8
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addRightOutline(int x, int y, String name, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-outline").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    layer.addActor(image);
    image.setPosition((x + 1) * CELL_SIZE - image.getWidth(), y * CELL_SIZE);
    return image;
}
 
Example 9
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addTopRightCornerTransition(String name, int x, int y, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("transitions/" + name + "-corner").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    layer.addActor(image);
    image.setRotation(-90);
    image.setPosition(x * CELL_SIZE, (y + 1) * CELL_SIZE);
    return image;
}
 
Example 10
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addTopLeftCornerTransition(String name, int x, int y, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("transitions/" + name + "-corner").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    layer.addActor(image);
    image.setPosition(x * CELL_SIZE, y * CELL_SIZE);
    return image;
}
 
Example 11
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addTopOutline(int x, int y, String name, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-outline").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    image.setRotation(90);
    layer.addActor(image);
    image.setPosition((x + 1) * CELL_SIZE, (y + 1) * CELL_SIZE - image.getWidth());
    return image;
}
 
Example 12
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Image addLeftOutline(int x, int y, String name, Group layer) {
    TextureAtlas.AtlasRegion region = Config.findRegions("tile/" + name + "-outline").random();
    if (region == null)
        return null;
    Image image = new Image(region);
    image.setRotation(180);
    layer.addActor(image);
    image.setPosition(x * CELL_SIZE + image.getWidth(), (y + 1) * CELL_SIZE);
    return image;
}
 
Example 13
Source File: Config.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static Array<TextureAtlas.AtlasRegion> findRegions(String regionName) {
    Array<TextureAtlas.AtlasRegion> result = foundRegions.get(regionName);
    if (result == null) {
        result = skin.getAtlas().findRegions(regionName);
        foundRegions.put(regionName, result);
    }
    return result;
}
 
Example 14
Source File: AtlasRegionDrawable.java    From TerraLegion with MIT License 4 votes vote down vote up
public TextureAtlas.AtlasRegion getTexture() {
	return atlasRegion;
}
 
Example 15
Source File: AtlasRegionDrawable.java    From TerraLegion with MIT License 4 votes vote down vote up
public AtlasRegionDrawable(TextureAtlas.AtlasRegion atlasRegion) {
	this.atlasRegion = atlasRegion;
}
 
Example 16
Source File: ResourceManager.java    From TerraLegion with MIT License 4 votes vote down vote up
public void loadAtlasRegionDrawable(String id, TextureAtlas atlas, String region) {
	TextureAtlas.AtlasRegion atlasRegion = atlas.findRegion(region);
	drawables.put(id, new AtlasRegionDrawable(atlasRegion));
}
 
Example 17
Source File: LibgdxTextureRegionWrapper.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a region from an {@link TextureAtlas.AtlasRegion}
 * @param atlasRegion
 */
public LibgdxTextureRegionWrapper(TextureAtlas.AtlasRegion atlasRegion) {
	super(atlasRegion);
	flip(false, true);
}
 
Example 18
Source File: RenderUtils.java    From jorbs-spire-mod with MIT License 4 votes vote down vote up
public static void renderAtlasRegionCenteredAt(SpriteBatch sb, TextureAtlas.AtlasRegion atlasRegion, float x, float y, Color color) {
    renderAtlasRegionCenteredAt(sb, atlasRegion, x, y, UNMODIFIED_SCALE, color, UNMODIFIED_ROTATION);
}
 
Example 19
Source File: RenderUtils.java    From jorbs-spire-mod with MIT License 4 votes vote down vote up
public static void renderAtlasRegionCenteredAt(SpriteBatch sb, TextureAtlas.AtlasRegion atlasRegion, float x, float y, float scale) {
    renderAtlasRegionCenteredAt(sb, atlasRegion, x, y, scale, UNMODIFIED_COLOR, UNMODIFIED_ROTATION);
}
 
Example 20
Source File: RenderUtils.java    From jorbs-spire-mod with MIT License 4 votes vote down vote up
public static void renderAtlasRegionCenteredAt(SpriteBatch sb, TextureAtlas.AtlasRegion atlasRegion, float x, float y) {
    renderAtlasRegionCenteredAt(sb, atlasRegion, x, y, UNMODIFIED_SCALE, UNMODIFIED_COLOR, UNMODIFIED_ROTATION);
}