本文整理汇总了Java中org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory.createFromSource方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapTextureAtlasTextureRegionFactory.createFromSource方法的具体用法?Java BitmapTextureAtlasTextureRegionFactory.createFromSource怎么用?Java BitmapTextureAtlasTextureRegionFactory.createFromSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory
的用法示例。
在下文中一共展示了BitmapTextureAtlasTextureRegionFactory.createFromSource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadSprite
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; //导入方法依赖的package包/类
private Sprite loadSprite(final float pCameraWidth, final float pCameraHeight, final TextureManager pTextureManager, final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final VertexBufferObjectManager pVertexBufferObjectManager) throws IllegalArgumentException {
this.mBitmapTextureAtlas = new BitmapTextureAtlas(pTextureManager, pBitmapTextureAtlasSource.getTextureWidth(), pBitmapTextureAtlasSource.getTextureHeight(), BitmapTextureFormat.RGBA_8888, TextureOptions.REPEATING_NEAREST);
final ITextureRegion textureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(this.mBitmapTextureAtlas, pBitmapTextureAtlasSource, 0, 0);
final int width = Math.round(pCameraWidth / this.mScale);
final int height = Math.round(pCameraHeight / this.mScale);
textureRegion.setTextureWidth(width);
textureRegion.setTextureHeight(height);
this.mBitmapTextureAtlas.load();
final Sprite sprite = new Sprite(0, 0, width, height, textureRegion, pVertexBufferObjectManager);
sprite.setScaleCenter(0, 0);
sprite.setScale(this.mScale);
return sprite;
}
示例2: getTextureRegion
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; //导入方法依赖的package包/类
private ITextureRegion getTextureRegion(String fileName, BitmapTextureAtlas bta) throws IOException {
InputStream in = null;
try {
in = gameActivity.getResources().getAssets().open("gfx/" + fileName);
return BitmapTextureAtlasTextureRegionFactory.createFromAsset(
bta, gameActivity, fileName, 0, 0);
} catch (IOException e) {
IBitmapTextureAtlasSource ats = FileBitmapTextureAtlasSource.createFromInternalStorage(
gameActivity, "/gfx/" + fileName, 0, 0);
return BitmapTextureAtlasTextureRegionFactory.createFromSource(bta, ats, 0, 0);
} finally {
if (in != null) {
in.close();
}
}
}
示例3: createBackground
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; //导入方法依赖的package包/类
private void createBackground(final Bitmap background, @Nullable final String backgroundUrl) {
if (background == null) return;
BitmapTextureAtlas bitmapTextureAtlas = new BitmapTextureAtlas(_engine.getTextureManager(), _width, _height, TextureOptions.BILINEAR);
IBitmapTextureAtlasSource baseTextureSource = new EmptyBitmapTextureAtlasSource(_width, _height);
final IBitmapTextureAtlasSource bitmapTextureAtlasSource = new BaseBitmapTextureAtlasSourceDecorator(baseTextureSource) {
@Override
protected void onDecorateBitmap(Canvas pCanvas) throws Exception {
if (backgroundUrl != null) {
Bitmap template = BitmapFactory.decodeStream(GoogleFlipGameApplication.sContext.getAssets().open(backgroundUrl));
pCanvas.drawBitmap(template, 0, 0, mPaint);
}
pCanvas.drawColor(_backgroundColor);
pCanvas.drawBitmap(background, 0, 0, mPaint);
}
@Override
public BaseBitmapTextureAtlasSourceDecorator deepCopy() {
throw new IModifier.DeepCopyNotSupportedException();
}
};
ITextureRegion mDecoratedBalloonTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(bitmapTextureAtlas, bitmapTextureAtlasSource,
0, 0);
bitmapTextureAtlas.load();
Sprite sprite = new Sprite(0, 0, mDecoratedBalloonTextureRegion, _engine.getVertexBufferObjectManager());
sprite.setOffsetCenter(0, 0);
sprite.setWidth(_width);
sprite.setHeight(_height);
_background = new SpriteBackground(sprite);
_engine.getScene().setBackground(_background);
}
示例4: setImageSourceFromAttributes
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; //导入方法依赖的package包/类
/**
*
* @param pAssetManager
* @param pTextureManager
* @param pAttributes
* @throws TMXParseException
*/
private void setImageSourceFromAttributes(final AssetManager pAssetManager, final TextureManager pTextureManager,
final Attributes pAttributes) throws TMXParseException {
final AssetBitmapTextureAtlasSource assetBitmapTextureAtlasSource = AssetBitmapTextureAtlasSource.create(
pAssetManager, this.mImageSource);
this.mTilesHorizontal = TMXTileSet.determineCount(assetBitmapTextureAtlasSource.getTextureWidth(),
this.mTileWidth, this.mMargin, this.mSpacing);
this.mTilesVertical = TMXTileSet.determineCount(assetBitmapTextureAtlasSource.getTextureHeight(),
this.mTileHeight, this.mMargin, this.mSpacing);
final BitmapTextureAtlas bitmapTextureAtlas = new BitmapTextureAtlas(pTextureManager,
assetBitmapTextureAtlasSource.getTextureWidth(), assetBitmapTextureAtlasSource.getTextureHeight(),
BitmapTextureFormat.RGBA_8888, this.mTextureOptions); // TODO
// Make
// TextureFormat
// variable
final String transparentColor = SAXUtils
.getAttribute(pAttributes, TMXConstants.TAG_IMAGE_ATTRIBUTE_TRANS, null);
if (transparentColor == null) {
BitmapTextureAtlasTextureRegionFactory.createFromSource(bitmapTextureAtlas, assetBitmapTextureAtlasSource,
0, 0);
} else {
try {
final int color = Color.parseColor((transparentColor.charAt(0) == '#') ? transparentColor : "#"
+ transparentColor);
BitmapTextureAtlasTextureRegionFactory.createFromSource(bitmapTextureAtlas,
new ColorKeyBitmapTextureAtlasSourceDecorator(assetBitmapTextureAtlasSource,
RectangleBitmapTextureAtlasSourceDecoratorShape.getDefaultInstance(), color), 0, 0);
} catch (final IllegalArgumentException e) {
throw new TMXParseException(
"Illegal value: '" + transparentColor + "' for attribute 'trans' supplied!", e);
}
}
/*
* Check we're using a manager, if so load in the texture and then map the text to source.
*/
if (this.mTMXTileSetSourceManager != null) {
this.mTexture = bitmapTextureAtlas;
this.mTexture.load();
this.mTMXTileSetSourceManager.addTileSetTexture(this.mImageSource, bitmapTextureAtlas);
this.mTMXTileSetSourceManager.addTileSourcesSize(this.mImageSource, new int[] { this.mTilesHorizontal,
this.mTilesHorizontal });
} else {
// No manager so load
this.mTexture = bitmapTextureAtlas;
this.mTexture.load();
}
}