当前位置: 首页>>代码示例>>Java>>正文


Java ITextureAtlasSource类代码示例

本文整理汇总了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;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:23,代码来源:BuildableTextureAtlasTextureRegionFactory.java

示例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;
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:23,代码来源:BuildableTextureAtlasTextureRegionFactory.java

示例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;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:11,代码来源:BuildableTextureAtlasTextureRegionFactory.java

示例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;
		}
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:13,代码来源:BuildableTextureAtlas.java

示例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);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:38,代码来源:BlackPawnTextureAtlasBuilder.java

示例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;
		}
	}
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:13,代码来源:BuildableTextureAtlas.java

示例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);
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:38,代码来源:BlackPawnTextureAtlasBuilder.java

示例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);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:4,代码来源:TextureRegionFactory.java

示例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);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:4,代码来源:TextureRegionFactory.java

示例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);
		}
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:73,代码来源:BlackPawnTextureAtlasBuilder.java


注:本文中的org.andengine.opengl.texture.atlas.source.ITextureAtlasSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。