com.ng.gdxutils.model.TextureManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gdx-utils Show documentation
Show all versions of gdx-utils Show documentation
A java library that used over libGdx game framework.
The newest version!
package com.ng.gdxutils.model;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
/**
* (c) 2016 Abhishek Aryan
*
* @author Abhishek Aryan
* @since 24-07-2016
*
*/
public class TextureManager {
public static Texture getPixmapTexture(Color color){
return new Texture(PixmapBuilder.getPixmapRectangle(1, 1, color));
}
public static TextureRegion getTextureRegion(TextureAtlas atlas, String regionName) {
TextureRegion textureRegion=atlas.findRegion(regionName);
return textureRegion;
}
public static Texture getTexture(String fileName) {
Texture localTexture = new Texture(Gdx.files.internal("pack/" + fileName));
localTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
return localTexture;
}
public static Texture getTexture(String paramString, AssetManager paramAssetManager) {
Texture localTexture=null;
if (!paramAssetManager.isLoaded("pack/" + paramString, Texture.class)) {
try {
localTexture = (Texture) paramAssetManager.get("pack/" + paramString, Texture.class);
localTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
} catch (Exception localException) {
localException.printStackTrace();
}
}
return localTexture;
}
public static TextureAtlas getAtlas(String fileName, AssetManager paramAssetManager) {
boolean bool = paramAssetManager.isLoaded("pack/" + fileName, TextureAtlas.class);
TextureAtlas localTextureAtlas = null;
if (bool) {
localTextureAtlas = (TextureAtlas)paramAssetManager.get("pack/" + fileName, TextureAtlas.class);
}
return localTextureAtlas;
}
public static TextureRegion[] getFrames(TextureAtlas paramTextureAtlas, String paramString, int paramInt1, int paramInt2) {
TextureRegion[] arrayOfTextureRegion = new TextureRegion[paramInt1 * paramInt2];
TextureRegion localTextureRegion = getTexture(paramTextureAtlas, paramString);
TextureRegion[][] arrayOfTextureRegion1 = localTextureRegion.split(localTextureRegion.getRegionWidth() / paramInt1, localTextureRegion.getRegionHeight() / paramInt2);
int k=0;
for (int i = 0; i
© 2015 - 2024 Weber Informatics LLC | Privacy Policy