本文整理汇总了Java中org.andengine.opengl.texture.region.TiledTextureRegion类的典型用法代码示例。如果您正苦于以下问题:Java TiledTextureRegion类的具体用法?Java TiledTextureRegion怎么用?Java TiledTextureRegion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TiledTextureRegion类属于org.andengine.opengl.texture.region包,在下文中一共展示了TiledTextureRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTiledTextureFromAsset
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
private TiledTextureRegion getTiledTextureFromAsset(final String path, int rows, int columns) {
try {
texture = new BitmapTexture(engine.getTextureManager(), new IInputStreamOpener() {
@Override
public InputStream open() throws IOException {
return context.getAssets().open("gfx/" + path); // path of the image
}
}, TextureOptions.BILINEAR);
texture.load();
return TextureRegionFactory.extractTiledFromTexture(texture, rows, columns);
} catch (IOException e) {
e.printStackTrace();
Log.e(ASSETS_ERROR_TAG, e.toString());
}
return null;
}
示例2: createTiledFromAssetDirectory
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
/**
* Loads all files from a given assets directory (in alphabetical order) as consecutive tiles of an {@link TiledTextureRegion}.
*
* @param pBuildableBitmapTextureAtlas
* @param pAssetManager
* @param pAssetSubdirectory to load all files from "gfx/flowers" put "flowers" here (assuming, that you've used {@link BitmapTextureAtlasTextureRegionFactory#setAssetBasePath(String)} with "gfx/" before.)
* @return
*/
public static TiledTextureRegion createTiledFromAssetDirectory(final BuildableBitmapTextureAtlas pBuildableBitmapTextureAtlas, final AssetManager pAssetManager, final String pAssetSubdirectory) {
final String[] files;
try {
files = pAssetManager.list(BitmapTextureAtlasTextureRegionFactory.sAssetBasePath + pAssetSubdirectory);
} catch (final IOException e) {
throw new AndEngineRuntimeException("Listing assets subdirectory: '" + BitmapTextureAtlasTextureRegionFactory.sAssetBasePath + pAssetSubdirectory + "' failed. Does it exist?", e);
}
final int fileCount = files.length;
final TextureRegion[] textures = new TextureRegion[fileCount];
for (int i = 0; i < fileCount; i++) {
final String assetPath = pAssetSubdirectory + "/" + files[i];
textures[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(pBuildableBitmapTextureAtlas, pAssetManager, assetPath);
}
return new TiledTextureRegion(pBuildableBitmapTextureAtlas, textures);
}
示例3: createTiledFromSource
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
public static <T extends ITextureAtlasSource, A extends ITextureAtlas<T>> TiledTextureRegion createTiledFromSource(final BuildableTextureAtlas<T, A> pBuildableTextureAtlas, final T pTextureAtlasSource, final int pTileColumns, final int pTileRows) {
final TiledTextureRegion tiledTextureRegion = TiledTextureRegion.create(pBuildableTextureAtlas, 0, 0, pTextureAtlasSource.getTextureWidth(), pTextureAtlasSource.getTextureHeight(), pTileColumns, pTileRows);
pBuildableTextureAtlas.addTextureAtlasSource(pTextureAtlasSource, new Callback<T>() {
@Override
public void onCallback(final T pCallbackValue) {
final int tileWidth = pTextureAtlasSource.getTextureWidth() / pTileColumns;
final int tileHeight = pTextureAtlasSource.getTextureHeight() / pTileRows;
for (int tileColumn = 0; tileColumn < pTileColumns; tileColumn++) {
for (int tileRow = 0; tileRow < pTileRows; tileRow++) {
final int tileIndex = tileRow * pTileColumns + tileColumn;
final int x = pCallbackValue.getTextureX() + tileColumn * tileWidth;
final int y = pCallbackValue.getTextureY() + tileRow * tileHeight;
tiledTextureRegion.setTexturePosition(tileIndex, x, y);
}
}
}
});
return tiledTextureRegion;
}
示例4: createTiledFromAssetDirectory
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
/**
* Loads all files from a given assets directory (in alphabetical order) as consecutive tiles of an {@link TiledTextureRegion}.
*
* @param pBuildableBitmapTextureAtlas
* @param pAssetManager
* @param pAssetSubdirectory to load all files from "gfx/flowers" put "flowers" here (assuming, that you've used {@link org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory#setAssetBasePath(String)} with "gfx/" before.)
* @return
*/
public static TiledTextureRegion createTiledFromAssetDirectory(final BuildableBitmapTextureAtlas pBuildableBitmapTextureAtlas, final AssetManager pAssetManager, final String pAssetSubdirectory) {
final String[] files;
try {
files = pAssetManager.list(BitmapTextureAtlasTextureRegionFactory.sAssetBasePath + pAssetSubdirectory);
} catch (final IOException e) {
throw new AndEngineRuntimeException("Listing assets subdirectory: '" + BitmapTextureAtlasTextureRegionFactory.sAssetBasePath + pAssetSubdirectory + "' failed. Does it exist?", e);
}
final int fileCount = files.length;
final TextureRegion[] textures = new TextureRegion[fileCount];
for (int i = 0; i < fileCount; i++) {
final String assetPath = pAssetSubdirectory + "/" + files[i];
textures[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(pBuildableBitmapTextureAtlas, pAssetManager, assetPath);
}
return new TiledTextureRegion(pBuildableBitmapTextureAtlas, textures);
}
示例5: createTiledFromSource
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
public static <T extends ITextureAtlasSource, A extends ITextureAtlas<T>> TiledTextureRegion createTiledFromSource(final BuildableTextureAtlas<T, A> pBuildableTextureAtlas, final T pTextureAtlasSource, final int pTileColumns, final int pTileRows) {
final TiledTextureRegion tiledTextureRegion = TiledTextureRegion.create(pBuildableTextureAtlas, 0, 0, pTextureAtlasSource.getTextureWidth(), pTextureAtlasSource.getTextureHeight(), pTileColumns, pTileRows);
pBuildableTextureAtlas.addTextureAtlasSource(pTextureAtlasSource, new Callback<T>() {
@Override
public void onCallback(final T pCallbackValue) {
final int tileWidth = pTextureAtlasSource.getTextureWidth() / pTileColumns;
final int tileHeight = pTextureAtlasSource.getTextureHeight() / pTileRows;
for(int tileColumn = 0; tileColumn < pTileColumns; tileColumn++) {
for(int tileRow = 0; tileRow < pTileRows; tileRow++) {
final int tileIndex = tileRow * pTileColumns + tileColumn;
final int x = pCallbackValue.getTextureX() + tileColumn * tileWidth;
final int y = pCallbackValue.getTextureY() + tileRow * tileHeight;
tiledTextureRegion.setTexturePosition(tileIndex, x, y);
}
}
}
});
return tiledTextureRegion;
}
示例6: getTiledTextureRegion
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
private TiledTextureRegion getTiledTextureRegion(String fileName, BitmapTextureAtlas bta, int column, int row) throws IOException {
InputStream in = null;
try {
in = gameActivity.getResources().getAssets().open("gfx/" + fileName);
return BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(
bta, gameActivity, fileName, 0, 0, column, row);
} catch (IOException e) {
IBitmapTextureAtlasSource ats = FileBitmapTextureAtlasSource.createFromInternalStorage(
gameActivity, "/gfx/" + fileName, 0, 0);
return BitmapTextureAtlasTextureRegionFactory.createTiledFromSource(
bta, ats, 0, 0, column, row);
} finally {
if (in != null) {
in.close();
}
}
}
示例7: loadSplashScene
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
protected void loadSplashScene() {
checkSetGFXPath();
BitmapTextureAtlas splashTextureAtlas = new BitmapTextureAtlas(textureManager, 1440, 2400, TextureOptions.BILINEAR);
TiledTextureRegion splashTextureRegion = BitmapTextureAtlasTextureRegionFactory.
createTiledFromAsset(splashTextureAtlas, this, ResMan.SPLASH, 0, 0, 1, 1);
splashTextureAtlas.load();
putTexture(ResMan.SPLASH, splashTextureRegion);
}
示例8: loadMenus
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
protected void loadMenus() {
checkSetGFXPath();
BitmapTextureAtlas menuAtlas = new BitmapTextureAtlas(this.getTextureManager(), 200, 150, TextureOptions.BILINEAR);
TiledTextureRegion menuBG = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(menuAtlas, this, ResMan.MENU_BG, 0, 0, 1, 1);
TiledTextureRegion menuNext = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(menuAtlas, this, ResMan.MENU_NEXT, 0, 0, 1, 1);
TiledTextureRegion menuReset = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(menuAtlas, this, ResMan.MENU_RESET, 0, 50, 1, 1);
TiledTextureRegion menuQuit = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(menuAtlas, this, ResMan.MENU_QUIT, 0, 100, 1, 1);
putTexture(ResMan.MENU_BG, menuBG);
putTexture(ResMan.MENU_RESET, menuReset);
putTexture(ResMan.MENU_NEXT, menuNext);
putTexture(ResMan.MENU_QUIT, menuQuit);
menuAtlas.load();
}
示例9: loadSplashScene
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
protected void loadSplashScene() {
checkSetGFXPath();
BitmapTextureAtlas splashTextureAtlas = new BitmapTextureAtlas(textureManager, 2400, 1440, TextureOptions.BILINEAR);
TiledTextureRegion splashTextureRegion = BitmapTextureAtlasTextureRegionFactory.
createTiledFromAsset(splashTextureAtlas, this, ResMan.SPLASH_LAND, 0, 0, 1, 1);
splashTextureAtlas.load();
putTexture(ResMan.SPLASH_LAND, splashTextureRegion);
}
示例10: loadGFXAsset
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
private String loadGFXAsset(GFXAsset asset) {
BitmapTextureAtlas textureAtlas = new BitmapTextureAtlas(textureManager, asset.getWidth(), asset.getHeight(), TextureOptions.BILINEAR);
final String filename = asset.getFilename();
final int textureX = asset.getTextureX();
final int textureY = asset.getTextureY();
final int tileC = asset.getTileColumns();
final int tileR = asset.getTileRows();
TiledTextureRegion tiledTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(textureAtlas, this, filename, textureX, textureY, tileC, tileR);
putTexture(filename, tiledTextureRegion);
textureAtlas.load();
return filename;
}
示例11: getInstance
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
/**
* イニシャライズ.
* @param gameActivity
* @return
*/
public static ResourceUtil getInstance(BaseGameActivity gameActivity) {
if (self == null) {
self = new ResourceUtil();
ResourceUtil.gameActivity = gameActivity;
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
textureRegionPool = new HashMap<String, ITextureRegion>();
tiledTextureRegionPool = new HashMap<String, TiledTextureRegion>();
}
return self;
}
示例12: Insect
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
public Insect(float initX, float initY, TiledTextureRegion textureRegion, VertexBufferObjectManager vbmo, int type) {
super(initX, initY, textureRegion, vbmo);
this.type = type;
this.name = Insect.INSECT_NAME[type];
this.score = Insect.INSECT_SCORE[type];
this.spawnTime = Insect.SPAWN_TIME[type];
this.speed = Insect.INSECT_SPEED[type];
moveDirection = 0;
moveTime = 100;
setSize(40.0f, 40.0f);
animate(100);
}
示例13: ButtonSprite
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
public ButtonSprite(final float pX, final float pY, final ITextureRegion pNormalTextureRegion, final VertexBufferObjectManager pVertexBufferObjectManager, final OnClickListener pOnClickListener) {
this(pX, pY, new TiledTextureRegion(pNormalTextureRegion.getTexture(), pNormalTextureRegion), pVertexBufferObjectManager, pOnClickListener);
}
示例14: createTiledFromAsset
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
public static TiledTextureRegion createTiledFromAsset(final BitmapTextureAtlas pBitmapTextureAtlas, final Context pContext, final String pAssetPath, final int pTextureX, final int pTextureY, final int pTileColumns, final int pTileRows) {
return BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(pBitmapTextureAtlas, pContext.getAssets(), pAssetPath, pTextureX, pTextureY, pTileColumns, pTileRows);
}
示例15: createTiledFromResource
import org.andengine.opengl.texture.region.TiledTextureRegion; //导入依赖的package包/类
public static TiledTextureRegion createTiledFromResource(final BitmapTextureAtlas pBitmapTextureAtlas, final Context pContext, final int pDrawableResourceID, final int pTextureX, final int pTextureY, final int pTileColumns, final int pTileRows) {
return BitmapTextureAtlasTextureRegionFactory.createTiledFromResource(pBitmapTextureAtlas, pContext.getResources(), pDrawableResourceID, pTextureX, pTextureY, pTileColumns, pTileRows);
}