Exception scenarios
Cause of exception
If the map canvas is not filled with a small square, the addTileByGlobalTileID of the TMXLayer cannot obtain the GlobalID and the texture square. Therefore, a Null Pointer exception is reported.
Solution
Modify the addTileByGlobalTileID method in the org. andengine. extension. tmx. TMXLayer class.
[Java] view plaincopy
If (pGlobalTileID = 0 ){
TmxTileTextureRegion = null;
} Else {
TmxTileTextureRegion = tmxTiledMap. getTextureRegionFromGlobalTileID (pGlobalTileID );
}
Change
[Java] view plaincopy
If (pGlobalTileID = 0 ){
TmxTileTextureRegion = tmxTiledMap. getTextureRegionFromGlobalTileID (1 );
} Else {
TmxTileTextureRegion = tmxTiledMap. getTextureRegionFromGlobalTileID (pGlobalTileID );
}
[Java] view plaincopy
This. drawWithoutChecks (tmxTileTextureRegion, tmxTile. getTileX (), tmxTile. getTileY (), tileWidth, tileHeight, Color. WHITE_ABGR_PACKED_FLOAT );
Change
[Java] view plaincopy
If (pGlobalTileID! = 0 ){
This. drawWithoutChecks (tmxTileTextureRegion, tmxTile. getTileX (), tmxTile. getTileY (), tileWidth, tileHeight, Color. WHITE_ABGR_PACKED_FLOAT );
}