๐ Hi, Iโm @nicolasgramlich
nicolasgramlich / andenginemultitouchextension Goto Github PK
View Code? Open in Web Editor NEWAndEngine - MultiTouch Extension
AndEngine - MultiTouch Extension
๐ Hi, Iโm @nicolasgramlich
Hi,
I am writing a game that uses TMX maps and tilesets. There is a tileset for the land (desert, water, hill, etc) and there is another tileset for the environment(trees, bushes, buildings, etc). The map has two layers. When I implemented this part and tried out, I got this exception:
10-07 23:00:55.598: E/AndroidRuntime(26679): java.lang.NullPointerException
10-07 23:00:55.598: E/AndroidRuntime(26679): at org.andengine.extension.tmx.TMXLayer.addTileByGlobalTileID(TMXLayer.java:277)
10-07 23:00:55.598: E/AndroidRuntime(26679): at org.andengine.extension.tmx.TMXLayer.initializeTMXTilesFromDataString(TMXLayer.java:247)
10-07 23:00:55.598: E/AndroidRuntime(26679): at org.andengine.extension.tmx.TMXParser.endElement(TMXParser.java:197)
10-07 23:00:55.598: E/AndroidRuntime(26679): at org.apache.harmony.xml.ExpatParser.endElement(ExpatParser.java:156)
if the pGlobalTileID is 0 this exception is always thrown.
With a small reordering this exception can be avoided:
private void addTileByGlobalTileID(final int pGlobalTileID,
final ITMXTilePropertiesListener pTMXTilePropertyListener) {
final TMXTiledMap tmxTiledMap = mTMXTiledMap;
final int tilesHorizontal = mTileColumns;
final int column = mTilesAdded % tilesHorizontal;
final int row = mTilesAdded / tilesHorizontal;
final TMXTile[][] tmxTiles = mTMXTiles;
final ITextureRegion tmxTileTextureRegion;
if (pGlobalTileID != 0) {
tmxTileTextureRegion = tmxTiledMap
.getTextureRegionFromGlobalTileID(pGlobalTileID);
final int tileHeight = mTMXTiledMap.getTileHeight();
final int tileWidth = mTMXTiledMap.getTileWidth();
if (mTexture == null) {
mTexture = tmxTileTextureRegion.getTexture();
super.initBlendFunction(mTexture);
} else {
if (mTexture != tmxTileTextureRegion.getTexture()) {
throw new AndEngineRuntimeException(
"All TMXTiles in a TMXLayer need to be in the same TMXTileSet.");
}
}
final TMXTile tmxTile = new TMXTile(pGlobalTileID, column, row,
tileWidth, tileHeight, tmxTileTextureRegion);
tmxTiles[row][column] = tmxTile;
setIndex(getSpriteBatchIndex(column, row));
this.drawWithoutChecks(tmxTileTextureRegion, tmxTile.getTileX(),
tmxTile.getTileY(), tileWidth, tileHeight,
Color.WHITE_ABGR_PACKED_FLOAT);
submit(); // TODO Doesn't need to be called here, but should rather
// be called in a "init" step, when parsing the XML is
// complete.
/* Notify the ITMXTilePropertiesListener if it exists. */
if (pTMXTilePropertyListener != null) {
final TMXProperties<TMXTileProperty> tmxTileProperties = tmxTiledMap
.getTMXTileProperties(pGlobalTileID);
if (tmxTileProperties != null) {
pTMXTilePropertyListener.onTMXTileWithPropertiesCreated(
tmxTiledMap, this, tmxTile, tmxTileProperties);
}
}
} else {
tmxTileTextureRegion = null;
}
mTilesAdded++;
}
what is your opinion?
Br
Szabolcs
A lot of people that are new to Andegine get this extension and then complain that they get errors.
There should be a readme added so it's clearer.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.