本文整理汇总了Java中org.andengine.util.SAXUtils.getIntAttributeOrThrow方法的典型用法代码示例。如果您正苦于以下问题:Java SAXUtils.getIntAttributeOrThrow方法的具体用法?Java SAXUtils.getIntAttributeOrThrow怎么用?Java SAXUtils.getIntAttributeOrThrow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.util.SAXUtils
的用法示例。
在下文中一共展示了SAXUtils.getIntAttributeOrThrow方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TMXTiledMap
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
TMXTiledMap(final Attributes pAttributes) {
this.mOrientation = pAttributes.getValue("", TMXConstants.TAG_MAP_ATTRIBUTE_ORIENTATION);
if (this.mOrientation.equals(TMXConstants.TAG_MAP_ATTRIBUTE_ORIENTATION_VALUE_ORTHOGONAL)) {
// We support this!
} else if (this.mOrientation.equals(TMXConstants.TAG_MAP_ATTRIBUTE_ORIENTATION_VALUE_ISOMETRIC)) {
// We support this!
} else {
throw new IllegalArgumentException(TMXConstants.TAG_MAP_ATTRIBUTE_ORIENTATION + ": '" + this.mOrientation
+ "' is not supported.");
}
this.mTileColumns = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_MAP_ATTRIBUTE_WIDTH);
this.mTilesRows = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_MAP_ATTRIBUTE_HEIGHT);
this.mTileWidth = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_MAP_ATTRIBUTE_TILEWIDTH);
this.mTileHeight = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_MAP_ATTRIBUTE_TILEHEIGHT);
}
示例2: startElement
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
@Override
public void startElement(final String pUri, final String pLocalName, final String pQualifiedName, final Attributes pAttributes) throws SAXException {
if(pLocalName.equals(TMXConstants.TAG_TILESET)){
this.mInTileset = true;
this.mTMXTileSet = new TMXTileSet(this.mFirstGlobalTileID, pAttributes, this.mTextureOptions, this.mTMXTileSetSourceManager);
} else if (pLocalName.equals(TMXConstants.TAG_OFFSET)){
this.mInTileOffset = true;
this.mTMXTileSet.addTileOffset(pAttributes);
} else if(pLocalName.equals(TMXConstants.TAG_IMAGE)){
this.mInImage = true;
this.mTMXTileSet.setImageSource(this.mAssetManager, this.mTextureManager, pAttributes);
} else if(pLocalName.equals(TMXConstants.TAG_TILE)) {
this.mInTile = true;
this.mLastTileSetTileID = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_TILE_ATTRIBUTE_ID);
} else if(pLocalName.equals(TMXConstants.TAG_PROPERTIES)) {
this.mInProperties = true;
} else if(pLocalName.equals(TMXConstants.TAG_PROPERTY)) {
this.mInProperty = true;
this.mTMXTileSet.addTMXTileProperty(this.mLastTileSetTileID, new TMXTileProperty(pAttributes));
} else {
throw new TMXParseException("Unexpected start tag: '" + pLocalName + "'.");
}
}
示例3: TMXObject
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
public TMXObject(final Attributes pAttributes) {
this.mName = pAttributes.getValue("", TMXConstants.TAG_OBJECT_ATTRIBUTE_NAME);
this.mType = pAttributes.getValue("", TMXConstants.TAG_OBJECT_ATTRIBUTE_TYPE);
this.mX = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_OBJECT_ATTRIBUTE_X);
this.mY = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_OBJECT_ATTRIBUTE_Y);
this.mWidth = SAXUtils.getIntAttribute(pAttributes, TMXConstants.TAG_OBJECT_ATTRIBUTE_WIDTH, 0);
this.mHeight = SAXUtils.getIntAttribute(pAttributes, TMXConstants.TAG_OBJECT_ATTRIBUTE_HEIGHT, 0);
this.mObjectType = TMXObjectType.RECTANGLE;
this.mPolygon_points = null;
this.mPolyline_points = null;
this.mGID = SAXUtils.getIntAttribute(pAttributes, TMXConstants.TAG_OBJECT_ATTRIBUTE_GID, -1);
if(this.mGID != -1){
this.mObjectType = TMXObjectType.TILEOBJECT;
}
}
示例4: startElement
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
@Override
public void startElement(final String pUri, final String pLocalName, final String pQualifiedName, final Attributes pAttributes) throws SAXException {
if (pLocalName.equals(TexturePackParser.TAG_TEXTURE)) {
this.mVersion = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTURE_ATTRIBUTE_VERSION);
this.mTexture = this.parseTexture(pAttributes);
this.mTextureRegionLibrary = new TexturePackTextureRegionLibrary(10);
this.mTexturePack = new TexturePack(this.mTexture, this.mTextureRegionLibrary);
} else if (pLocalName.equals(TexturePackParser.TAG_TEXTUREREGION)) {
final int id = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_ID);
final int x = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_X);
final int y = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_Y);
final int width = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_WIDTH);
final int height = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_HEIGHT);
final String source = SAXUtils.getAttributeOrThrow(pAttributes, TAG_TEXTUREREGION_ATTRIBUTE_SOURCE);
// TODO Not sure how trimming could be transparently supported...
final boolean trimmed = SAXUtils.getBooleanAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_TRIMMED);
final boolean rotated = SAXUtils.getBooleanAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_ROTATED);
final int sourceX = SAXUtils.getIntAttributeOrThrow(pAttributes, TAG_TEXTUREREGION_ATTRIBUTE_SOURCE_X);
final int sourceY = SAXUtils.getIntAttributeOrThrow(pAttributes, TAG_TEXTUREREGION_ATTRIBUTE_SOURCE_Y);
final int sourceWidth = SAXUtils.getIntAttributeOrThrow(pAttributes, TAG_TEXTUREREGION_ATTRIBUTE_SOURCE_WIDTH);
final int sourceHeight = SAXUtils.getIntAttributeOrThrow(pAttributes, TAG_TEXTUREREGION_ATTRIBUTE_SOURCE_HEIGHT);
this.mTextureRegionLibrary.put(new TexturePackTextureRegion(this.mTexture, x, y, width, height, id, source, rotated, trimmed, sourceX, sourceY, sourceWidth, sourceHeight));
} else {
throw new TexturePackParseException("Unexpected tag: '" + pLocalName + "'.");
}
}
示例5: startElement
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
@Override
public void startElement(final String pUri, final String pLocalName, final String pQualifiedName, final Attributes pAttributes) throws SAXException {
if (pLocalName.equals(AnimationPackParser.TAG_ANIMATIONPACK)) {
final int version = SAXUtils.getIntAttributeOrThrow(pAttributes, AnimationPackParser.TAG_ANIMATIONPACK_ATTRIBUTE_VERSION);
if (version != 1) {
throw new AnimationPackParseException("Unexpected version: '" + version + "'.");
}
this.mTexturePackLoader = new TexturePackLoader(this.mAssetManager, this.mTextureManager);
this.mTexturePackLibrary = new TexturePackLibrary();
this.mAnimationPackTiledTextureRegionLibrary = new AnimationPackTiledTextureRegionLibrary();
this.mAnimationPack = new AnimationPack(this.mTexturePackLibrary, this.mAnimationPackTiledTextureRegionLibrary);
} else if (pLocalName.equals(AnimationPackParser.TAG_TEXTUREPACKS)) {
/* Nothing. */
} else if (pLocalName.equals(AnimationPackParser.TAG_TEXTUREPACK)) {
final String texturePackName = SAXUtils.getAttributeOrThrow(pAttributes, AnimationPackParser.TAG_TEXTUREPACK_ATTRIBUTE_FILENAME);
final String texturePackPath = this.mAssetBasePath + texturePackName;
final TexturePack texturePack = this.mTexturePackLoader.loadFromAsset(texturePackPath, this.mAssetBasePath);
this.mTexturePackLibrary.put(texturePackName, texturePack);
texturePack.loadTexture();
} else if (pLocalName.equals(AnimationPackParser.TAG_ANIMATIONS)) {
/* Nothing. */
} else if (pLocalName.equals(AnimationPackParser.TAG_ANIMATION)) {
this.mCurrentAnimationName = SAXUtils.getAttributeOrThrow(pAttributes, AnimationPackParser.TAG_ANIMATION_ATTRIBUTE_NAME);
this.mCurrentAnimationLoopCount = SAXUtils.getIntAttribute(pAttributes, AnimationPackParser.TAG_ANIMATION_ATTRIBUTE_LOOPCOUNT, IAnimationData.LOOP_CONTINUOUS);
} else if (pLocalName.equals(AnimationPackParser.TAG_ANIMATIONFRAME)) {
final int duration = SAXUtils.getIntAttributeOrThrow(pAttributes, AnimationPackParser.TAG_ANIMATIONFRAME_ATTRIBUTE_DURATION);
this.mCurrentAnimationFrameDurations.add(duration);
final String textureRegionName = SAXUtils.getAttributeOrThrow(pAttributes, AnimationPackParser.TAG_ANIMATIONFRAME_ATTRIBUTE_TEXTUREREGION);
final TexturePackTextureRegion texturePackTextureRegion = this.mTexturePackLibrary.getTexturePackTextureRegion(textureRegionName);
this.mCurrentAnimationFrameTexturePackTextureRegions.add(texturePackTextureRegion);
} else {
throw new AnimationPackParseException("Unexpected tag: '" + pLocalName + "'.");
}
}
示例6: startElement
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
@Override
public void startElement(final String pUri, final String pLocalName, final String pQualifiedName, final Attributes pAttributes) throws SAXException {
if(pLocalName.equals(TexturePackParser.TAG_TEXTURE)) {
this.mVersion = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTURE_ATTRIBUTE_VERSION);
this.mTexture = this.parseTexture(pAttributes);
this.mTextureRegionLibrary = new TexturePackTextureRegionLibrary(10);
this.mTexturePack = new TexturePack(this.mTexture, this.mTextureRegionLibrary);
} else if(pLocalName.equals(TexturePackParser.TAG_TEXTUREREGION)) {
final int id = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_ID);
final int x = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_X);
final int y = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_Y);
final int width = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_WIDTH);
final int height = SAXUtils.getIntAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_HEIGHT);
final String source = SAXUtils.getAttributeOrThrow(pAttributes, TAG_TEXTUREREGION_ATTRIBUTE_SOURCE);
// TODO Not sure how trimming could be transparently supported...
final boolean trimmed = SAXUtils.getBooleanAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_TRIMMED);
final boolean rotated = SAXUtils.getBooleanAttributeOrThrow(pAttributes, TexturePackParser.TAG_TEXTUREREGION_ATTRIBUTE_ROTATED);
final int sourceX = SAXUtils.getIntAttributeOrThrow(pAttributes, TAG_TEXTUREREGION_ATTRIBUTE_SOURCE_X);
final int sourceY = SAXUtils.getIntAttributeOrThrow(pAttributes, TAG_TEXTUREREGION_ATTRIBUTE_SOURCE_Y);
final int sourceWidth = SAXUtils.getIntAttributeOrThrow(pAttributes, TAG_TEXTUREREGION_ATTRIBUTE_SOURCE_WIDTH);
final int sourceHeight = SAXUtils.getIntAttributeOrThrow(pAttributes, TAG_TEXTUREREGION_ATTRIBUTE_SOURCE_HEIGHT);
this.mTextureRegionLibrary.put(new TexturePackTextureRegion(this.mTexture, x, y, width, height, id, source, rotated, trimmed, sourceX, sourceY, sourceWidth, sourceHeight));
} else {
throw new TexturePackParseException("Unexpected tag: '" + pLocalName + "'.");
}
}
示例7: startElement
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
@Override
public void startElement(final String pUri, final String pLocalName, final String pQualifiedName, final Attributes pAttributes) throws SAXException {
if(pLocalName.equals(AnimationPackParser.TAG_ANIMATIONPACK)) {
final int version = SAXUtils.getIntAttributeOrThrow(pAttributes, AnimationPackParser.TAG_ANIMATIONPACK_ATTRIBUTE_VERSION);
if(version != 1) {
throw new AnimationPackParseException("Unexpected version: '" + version + "'.");
}
this.mTexturePackLoader = new TexturePackLoader(this.mAssetManager, this.mTextureManager);
this.mTexturePackLibrary = new TexturePackLibrary();
this.mAnimationPackTiledTextureRegionLibrary = new AnimationPackTiledTextureRegionLibrary();
this.mAnimationPack = new AnimationPack(this.mTexturePackLibrary, this.mAnimationPackTiledTextureRegionLibrary);
} else if(pLocalName.equals(AnimationPackParser.TAG_TEXTUREPACKS)) {
/* Nothing. */
} else if(pLocalName.equals(AnimationPackParser.TAG_TEXTUREPACK)) {
final String texturePackName = SAXUtils.getAttributeOrThrow(pAttributes, AnimationPackParser.TAG_TEXTUREPACK_ATTRIBUTE_FILENAME);
final String texturePackPath = this.mAssetBasePath + texturePackName;
final TexturePack texturePack = this.mTexturePackLoader.loadFromAsset(texturePackPath, this.mAssetBasePath);
this.mTexturePackLibrary.put(texturePackName, texturePack);
texturePack.loadTexture();
} else if(pLocalName.equals(AnimationPackParser.TAG_ANIMATIONS)) {
/* Nothing. */
} else if(pLocalName.equals(AnimationPackParser.TAG_ANIMATION)) {
this.mCurrentAnimationName = SAXUtils.getAttributeOrThrow(pAttributes, AnimationPackParser.TAG_ANIMATION_ATTRIBUTE_NAME);
this.mCurrentAnimationLoopCount = SAXUtils.getIntAttribute(pAttributes, AnimationPackParser.TAG_ANIMATION_ATTRIBUTE_LOOPCOUNT, IAnimationData.LOOP_CONTINUOUS);
} else if(pLocalName.equals(AnimationPackParser.TAG_ANIMATIONFRAME)) {
final int duration = SAXUtils.getIntAttributeOrThrow(pAttributes, AnimationPackParser.TAG_ANIMATIONFRAME_ATTRIBUTE_DURATION);
this.mCurrentAnimationFrameDurations.add(duration);
final String textureRegionName = SAXUtils.getAttributeOrThrow(pAttributes, AnimationPackParser.TAG_ANIMATIONFRAME_ATTRIBUTE_TEXTUREREGION);
final TexturePackTextureRegion texturePackTextureRegion = this.mTexturePackLibrary.getTexturePackTextureRegion(textureRegionName);
this.mCurrentAnimationFrameTexturePackTextureRegions.add(texturePackTextureRegion);
} else {
throw new AnimationPackParseException("Unexpected tag: '" + pLocalName + "'.");
}
}
示例8: getLayerCapacity
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
private int getLayerCapacity(final Attributes pAttributes){
int capacity = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_LAYER_ATTRIBUTE_WIDTH) * SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_LAYER_ATTRIBUTE_HEIGHT);
return capacity;
}
示例9: TMXObjectGroup
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
public TMXObjectGroup(final Attributes pAttributes) {
this.mName = pAttributes.getValue("", TMXConstants.TAG_OBJECTGROUP_ATTRIBUTE_NAME);
this.mWidth = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_OBJECTGROUP_ATTRIBUTE_WIDTH);
this.mHeight = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_OBJECTGROUP_ATTRIBUTE_HEIGHT);
}
示例10: TMXLayer
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
/**
* This reads in the attributes and creates a standard {@link SpriteBatch}
* which uses a {@link HighPerformanceSpriteBatchVertexBufferObject}
*
* @param pTMXTiledMap
* @param pAttributes
* @param pVertexBufferObjectManager
* @param pAllocateTiles
*/
public TMXLayer(final TMXTiledMap pTMXTiledMap, final Attributes pAttributes,
final VertexBufferObjectManager pVertexBufferObjectManager, boolean pAllocateTiles) {
super(null, SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_LAYER_ATTRIBUTE_WIDTH)
* SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_LAYER_ATTRIBUTE_HEIGHT),
pVertexBufferObjectManager);
this.mTMXTiledMap = pTMXTiledMap;
this.mName = pAttributes.getValue("", TMXConstants.TAG_LAYER_ATTRIBUTE_NAME);
this.mTileColumns = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_LAYER_ATTRIBUTE_WIDTH);
this.mTileRows = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_LAYER_ATTRIBUTE_HEIGHT);
if (pAllocateTiles) {
this.mAllocateTMXTiles = true;
this.mTMXTiles = new TMXTile[this.mTileRows][this.mTileColumns];
} else {
this.mAllocateTMXTiles = false;
this.mTMXTiles = null;
}
this.mTileGID = new int[this.mTileRows][this.mTileColumns];
this.mStoreGID = this.mTMXTiledMap.getStoreGID();
this.mWidth = pTMXTiledMap.getTileWidth() * this.mTileColumns;
this.mHeight = pTMXTiledMap.getTileHeight() * this.mTileRows;
this.mRotationCenterX = this.mWidth * 0.5f;
this.mRotationCenterY = this.mHeight * 0.5f;
this.mScaleCenterX = this.mRotationCenterX;
this.mScaleCenterY = this.mRotationCenterY;
this.mGlobalTileIDsExpected = this.mTileColumns * this.mTileRows;
this.setVisible(SAXUtils.getIntAttribute(pAttributes, TMXConstants.TAG_LAYER_ATTRIBUTE_VISIBLE,
TMXConstants.TAG_LAYER_ATTRIBUTE_VISIBLE_VALUE_DEFAULT) == 1);
this.setAlpha(SAXUtils.getFloatAttribute(pAttributes, TMXConstants.TAG_LAYER_ATTRIBUTE_OPACITY,
TMXConstants.TAG_LAYER_ATTRIBUTE_OPACITY_VALUE_DEFAULT));
if (this.mTMXTiledMap.getOrientation().equals(TMXConstants.TAG_MAP_ATTRIBUTE_ORIENTATION_VALUE_ISOMETRIC)) {
// Paul Robinson
// Calculate the half of the tile height and width, saves doing it
// later
this.mIsoHalfTileHeight = this.mTMXTiledMap.getTileHeight() / 2;
this.mIsoHalfTileWidth = this.mTMXTiledMap.getTileWidth() / 2;
this.tileratio = this.mTMXTiledMap.getTileWidth() / this.mTMXTiledMap.getTileHeight();
this.setIsometricDrawMethod(this.mTMXTiledMap.getIsometricDrawMethod());
}
}
示例11: TMXTileSet
import org.andengine.util.SAXUtils; //导入方法依赖的package包/类
/**
* Create a new {@link TMXTileSet}
*
* @param pFirstGlobalTileID
* {@link Integer} of the first global tile id.
* @param pAttributes
* {@link Attributes} from XML.
* @param pTextureOptions
* {@link TextureOptions} to use
* @param pTMXTileSetSourceManager
* {@link TMXTileSetSourceManager} to use. Can pass
* <code>null</code> if you don't want to use one.
*/
TMXTileSet(final int pFirstGlobalTileID, final Attributes pAttributes, final TextureOptions pTextureOptions,
TMXTileSetSourceManager pTMXTileSetSourceManager) {
this.mFirstGlobalTileID = pFirstGlobalTileID;
this.mName = pAttributes.getValue("", TMXConstants.TAG_TILESET_ATTRIBUTE_NAME);
this.mTileWidth = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_TILESET_ATTRIBUTE_TILEWIDTH);
this.mTileHeight = SAXUtils.getIntAttributeOrThrow(pAttributes, TMXConstants.TAG_TILESET_ATTRIBUTE_TILEHEIGHT);
this.mSpacing = SAXUtils.getIntAttribute(pAttributes, TMXConstants.TAG_TILESET_ATTRIBUTE_SPACING, 0);
this.mMargin = SAXUtils.getIntAttribute(pAttributes, TMXConstants.TAG_TILESET_ATTRIBUTE_MARGIN, 0);
this.mTextureOptions = pTextureOptions;
this.mTMXTileSetSourceManager = pTMXTileSetSourceManager;
}