我正在使用平铺为我的游戏创建地图。我正在使用 AndEngine 框架在 android 中开发游戏。在 OnLoadResource 方法中,我正在使用加载地图方法加载 tmx 文件。当游戏构建时,它会在这一行抛出“不幸地停止工作”。起初它显示,它找不到图像,我清除了该错误。现在在这条线游戏停止。请帮助我,因为我是基于瓷砖的游戏的新手。
this.mTMXTiledMap = mTMXLoader.loadFromAsset(this,"tmx/levelmap.tmx");
这是代码片段:
private void loadMap()
{
this.mRepeatingSpriteBackground = new RepeatingSpriteBackground(CAMERA_WIDTH,CAMERA_HEIGHT, this.mEngine.getTextureManager(),new AssetBitmapTextureAtlasSource(this, mapBG), 1.0f);
try
{
final TMXLoader mTMXLoader = new TMXLoader(this, this.mEngine.getTextureManager(), TextureOptions.BILINEAR_PREMULTIPLYALPHA, null);
this.mTMXTiledMap = mTMXLoader.loadFromAsset(this,"tmx/levelmap.tmx");
}
catch (final TMXLoadException tmxle)
{
Debug.e(tmxle);
}
}
这是Logcat:
01-18 19:37:52.759: E/AndroidRuntime(643): java.lang.ArithmeticException: divide by zero
01-18 19:37:52.759: E/AndroidRuntime(643): at org.anddev.andengine.entity.layer.tiled.tmx.TMXTileSet.getTextureRegionFromGlobalTileID(TMXTileSet.java:154)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.anddev.andengine.entity.layer.tiled.tmx.TMXTiledMap.getTextureRegionFromGlobalTileID(TMXTiledMap.java:193)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.anddev.andengine.entity.layer.tiled.tmx.TMXLayer.addTileByGlobalTileID(TMXLayer.java:289)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.anddev.andengine.entity.layer.tiled.tmx.TMXLayer.initializeTMXTilesFromDataString(TMXLayer.java:268)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.anddev.andengine.entity.layer.tiled.tmx.TMXParser.endElement(TMXParser.java:193)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.apache.harmony.xml.ExpatParser.endElement(ExpatParser.java:156)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.anddev.andengine.entity.layer.tiled.tmx.TMXLoader.load(TMXLoader.java:93)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.anddev.andengine.entity.layer.tiled.tmx.TMXLoader.loadFromAsset(TMXLoader.java:78)
01-18 19:37:52.759: E/AndroidRuntime(643): at apk.games.robowars.RoboWars.loadMap(RoboWars.java:577)
01-18 19:37:52.759: E/AndroidRuntime(643): at apk.games.robowars.RoboWars.onLoadResources(RoboWars.java:248)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.anddev.andengine.ui.activity.BaseGameActivity.doResume(BaseGameActivity.java:168)
01-18 19:37:52.759: E/AndroidRuntime(643): at org.anddev.andengine.ui.activity.BaseGameActivity.onWindowFocusChanged(BaseGameActivity.java:85)
01-18 19:37:52.759: E/AndroidRuntime(643): at com.android.internal.policy.impl.PhoneWindow$DecorView.onWindowFocusChanged(PhoneWindow.java:2423)