本文整理汇总了Java中org.andengine.opengl.texture.atlas.source.ITextureAtlasSource类的典型用法代码示例。如果您正苦于以下问题:Java ITextureAtlasSource类的具体用法?Java ITextureAtlasSource怎么用?Java ITextureAtlasSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITextureAtlasSource类属于org.andengine.opengl.texture.atlas.source包,在下文中一共展示了ITextureAtlasSource类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTiledFromSource
import org.andengine.opengl.texture.atlas.source.ITextureAtlasSource; //导入依赖的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;
}
示例2: createTiledFromSource
import org.andengine.opengl.texture.atlas.source.ITextureAtlasSource; //导入依赖的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;
}
示例3: createFromSource
import org.andengine.opengl.texture.atlas.source.ITextureAtlasSource; //导入依赖的package包/类
public static <T extends ITextureAtlasSource, A extends ITextureAtlas<T>> TextureRegion createFromSource(final BuildableTextureAtlas<T, A> pBuildableTextureAtlas, final T pTextureAtlasSource, final boolean pRotated) {
final TextureRegion textureRegion = new TextureRegion(pBuildableTextureAtlas, 0, 0, pTextureAtlasSource.getTextureWidth(), pTextureAtlasSource.getTextureHeight(), pRotated);
pBuildableTextureAtlas.addTextureAtlasSource(pTextureAtlasSource, new Callback<T>() {
@Override
public void onCallback(final T pCallbackValue) {
textureRegion.setTexturePosition(pCallbackValue.getTextureX(), pCallbackValue.getTextureY());
}
});
return textureRegion;
}
示例4: removeTextureAtlasSource
import org.andengine.opengl.texture.atlas.source.ITextureAtlasSource; //导入依赖的package包/类
@Override
public void removeTextureAtlasSource(final ITextureAtlasSource pTextureAtlasSource) {
final ArrayList<TextureAtlasSourceWithWithLocationCallback<S>> textureSources = this.mTextureAtlasSourcesToPlace;
for (int i = textureSources.size() - 1; i >= 0; i--) {
final TextureAtlasSourceWithWithLocationCallback<S> textureSource = textureSources.get(i);
if (textureSource.mTextureAtlasSource == pTextureAtlasSource) {
textureSources.remove(i);
this.mTextureAtlas.setUpdateOnHardwareNeeded(true);
return;
}
}
}
示例5: createChildren
import org.andengine.opengl.texture.atlas.source.ITextureAtlasSource; //导入依赖的package包/类
private Node createChildren(final ITextureAtlasSource pTextureAtlasSource, final int pTextureWidth, final int pTextureHeight, final int pTextureAtlasSourceSpacing, final int pTextureAtlasSourcePadding, final int pDeltaWidth, final int pDeltaHeight) {
final Rect rect = this.mRect;
if (pDeltaWidth >= pDeltaHeight) {
/* Split using a vertical axis. */
this.mChildA = new Node(
rect.getLeft(),
rect.getTop(),
pTextureAtlasSource.getTextureWidth() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding,
rect.getHeight()
);
this.mChildB = new Node(
rect.getLeft() + (pTextureAtlasSource.getTextureWidth() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding),
rect.getTop(),
rect.getWidth() - (pTextureAtlasSource.getTextureWidth() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding),
rect.getHeight()
);
} else {
/* Split using a horizontal axis. */
this.mChildA = new Node(
rect.getLeft(),
rect.getTop(),
rect.getWidth(),
pTextureAtlasSource.getTextureHeight() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding
);
this.mChildB = new Node(
rect.getLeft(),
rect.getTop() + (pTextureAtlasSource.getTextureHeight() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding),
rect.getWidth(),
rect.getHeight() - (pTextureAtlasSource.getTextureHeight() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding)
);
}
return this.mChildA.insert(pTextureAtlasSource, pTextureWidth, pTextureHeight, pTextureAtlasSourceSpacing, pTextureAtlasSourcePadding);
}
示例6: removeTextureAtlasSource
import org.andengine.opengl.texture.atlas.source.ITextureAtlasSource; //导入依赖的package包/类
@Override
public void removeTextureAtlasSource(final ITextureAtlasSource pTextureAtlasSource) {
final ArrayList<TextureAtlasSourceWithWithLocationCallback<S>> textureSources = this.mTextureAtlasSourcesToPlace;
for(int i = textureSources.size() - 1; i >= 0; i--) {
final TextureAtlasSourceWithWithLocationCallback<S> textureSource = textureSources.get(i);
if(textureSource.mTextureAtlasSource == pTextureAtlasSource) {
textureSources.remove(i);
this.mTextureAtlas.setUpdateOnHardwareNeeded(true);
return;
}
}
}
示例7: createChildren
import org.andengine.opengl.texture.atlas.source.ITextureAtlasSource; //导入依赖的package包/类
private Node createChildren(final ITextureAtlasSource pTextureAtlasSource, final int pTextureWidth, final int pTextureHeight, final int pTextureAtlasSourceSpacing, final int pTextureAtlasSourcePadding, final int pDeltaWidth, final int pDeltaHeight) {
final Rect rect = this.mRect;
if(pDeltaWidth >= pDeltaHeight) {
/* Split using a vertical axis. */
this.mChildA = new Node(
rect.getLeft(),
rect.getTop(),
pTextureAtlasSource.getTextureWidth() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding,
rect.getHeight()
);
this.mChildB = new Node(
rect.getLeft() + (pTextureAtlasSource.getTextureWidth() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding),
rect.getTop(),
rect.getWidth() - (pTextureAtlasSource.getTextureWidth() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding),
rect.getHeight()
);
} else {
/* Split using a horizontal axis. */
this.mChildA = new Node(
rect.getLeft(),
rect.getTop(),
rect.getWidth(),
pTextureAtlasSource.getTextureHeight() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding
);
this.mChildB = new Node(
rect.getLeft(),
rect.getTop() + (pTextureAtlasSource.getTextureHeight() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding),
rect.getWidth(),
rect.getHeight() - (pTextureAtlasSource.getTextureHeight() + pTextureAtlasSourceSpacing + 2 * pTextureAtlasSourcePadding)
);
}
return this.mChildA.insert(pTextureAtlasSource, pTextureWidth, pTextureHeight, pTextureAtlasSourceSpacing, pTextureAtlasSourcePadding);
}
示例8: createFromSource
import org.andengine.opengl.texture.atlas.source.ITextureAtlasSource; //导入依赖的package包/类
public static <T extends ITextureAtlasSource> TextureRegion createFromSource(final ITextureAtlas<T> pTextureAtlas, final T pTextureAtlasSource, final int pTextureX, final int pTextureY) {
return TextureRegionFactory.createFromSource(pTextureAtlas, pTextureAtlasSource, pTextureX, pTextureY, false);
}
示例9: createTiledFromSource
import org.andengine.opengl.texture.atlas.source.ITextureAtlasSource; //导入依赖的package包/类
public static <T extends ITextureAtlasSource> TiledTextureRegion createTiledFromSource(final ITextureAtlas<T> pTextureAtlas, final T pTextureAtlasSource, final int pTextureX, final int pTextureY, final int pTileColumns, final int pTileRows) {
return TextureRegionFactory.createTiledFromSource(pTextureAtlas, pTextureAtlasSource, pTextureX, pTextureY, pTileColumns, pTileRows, false);
}
示例10: insert
import org.andengine.opengl.texture.atlas.source.ITextureAtlasSource; //导入依赖的package包/类
public Node insert(final ITextureAtlasSource pTextureAtlasSource, final int pTextureWidth, final int pTextureHeight, final int pTextureAtlasSourceSpacing, final int pTextureAtlasSourcePadding) throws IllegalArgumentException {
if (this.mChildA != null && this.mChildB != null) {
final Node newNode = this.mChildA.insert(pTextureAtlasSource, pTextureWidth, pTextureHeight, pTextureAtlasSourceSpacing, pTextureAtlasSourcePadding);
if (newNode != null) {
return newNode;
} else {
return this.mChildB.insert(pTextureAtlasSource, pTextureWidth, pTextureHeight, pTextureAtlasSourceSpacing, pTextureAtlasSourcePadding);
}
} else {
if (this.mTextureAtlasSource != null) {
return null;
}
final int textureSourceWidth = pTextureAtlasSource.getTextureWidth() + 2 * pTextureAtlasSourcePadding;
final int textureSourceHeight = pTextureAtlasSource.getTextureHeight() + 2 * pTextureAtlasSourcePadding;
final int rectWidth = this.mRect.getWidth();
final int rectHeight = this.mRect.getHeight();
if (textureSourceWidth > rectWidth || textureSourceHeight > rectHeight) {
return null;
}
final int textureSourceWidthWithSpacing = textureSourceWidth + pTextureAtlasSourceSpacing;
final int textureSourceHeightWithSpacing = textureSourceHeight + pTextureAtlasSourceSpacing;
final int rectLeft = this.mRect.getLeft();
final int rectTop = this.mRect.getTop();
final boolean fitToBottomWithoutSpacing = textureSourceHeight == rectHeight && rectTop + textureSourceHeight == pTextureHeight;
final boolean fitToRightWithoutSpacing = textureSourceWidth == rectWidth && rectLeft + textureSourceWidth == pTextureWidth;
if (textureSourceWidthWithSpacing == rectWidth) {
if (textureSourceHeightWithSpacing == rectHeight) { /* Normal case with padding. */
this.mTextureAtlasSource = pTextureAtlasSource;
return this;
} else if (fitToBottomWithoutSpacing) { /* Bottom edge of the BitmapTexture. */
this.mTextureAtlasSource = pTextureAtlasSource;
return this;
}
}
if (fitToRightWithoutSpacing) { /* Right edge of the BitmapTexture. */
if (textureSourceHeightWithSpacing == rectHeight) {
this.mTextureAtlasSource = pTextureAtlasSource;
return this;
} else if (fitToBottomWithoutSpacing) { /* Bottom edge of the BitmapTexture. */
this.mTextureAtlasSource = pTextureAtlasSource;
return this;
} else if (textureSourceHeightWithSpacing > rectHeight) {
return null;
} else {
return this.createChildren(pTextureAtlasSource, pTextureWidth, pTextureHeight, pTextureAtlasSourceSpacing, pTextureAtlasSourcePadding, rectWidth - textureSourceWidth, rectHeight - textureSourceHeightWithSpacing);
}
}
if (fitToBottomWithoutSpacing) {
if (textureSourceWidthWithSpacing == rectWidth) {
this.mTextureAtlasSource = pTextureAtlasSource;
return this;
} else if (textureSourceWidthWithSpacing > rectWidth) {
return null;
} else {
return this.createChildren(pTextureAtlasSource, pTextureWidth, pTextureHeight, pTextureAtlasSourceSpacing, pTextureAtlasSourcePadding, rectWidth - textureSourceWidthWithSpacing, rectHeight - textureSourceHeight);
}
} else if (textureSourceWidthWithSpacing > rectWidth || textureSourceHeightWithSpacing > rectHeight) {
return null;
} else {
return this.createChildren(pTextureAtlasSource, pTextureWidth, pTextureHeight, pTextureAtlasSourceSpacing, pTextureAtlasSourcePadding, rectWidth - textureSourceWidthWithSpacing, rectHeight - textureSourceHeightWithSpacing);
}
}
}