Open ghost opened 12 years ago
Getting the offsetPosition for the objectgroup can throw an Exception when attempting to cast a null value to an integer. THis is caused when there is no x or y attributes in the objectgroup key. This will result in the TMXMapInfo objectGroup information not being parsed, and map.objectGroupNamed("group name") will not return any groups. I fixed in my build by changing line 289 from: positionOffset.x = Integer.parseInt( attributes.getValue( "x" ) ) * tileSize.width; positionOffset.y = Integer.parseInt( attributes.getValue( "y" ) ) * tileSize.height; objectGroup.positionOffset = positionOffset;
TO: try { positionOffset.x = Integer.parseInt( attributes.getValue( "x" ) ) * tileSize.width; positionOffset.y = Integer.parseInt( attributes.getValue( "y" ) ) * tileSize.height;
objectGroup.positionOffset = positionOffset;
}
catch( Exception e )
{
ccMacros.CCLOG( LOG_TAG, "TMXFile: objectgroup does not have a defined x or y value. Defaulting to 0." );
objectGroup.positionOffset = CGPoint.zero();
}
parseXMLFile() does not display a friendly error message, the stacktrace().toString() method does not provide any useful information. There are a number of opportunities for a NumberFormatException.