2d瓷砖地图没有在android中使用屏幕显示地图

时间:2013-01-18 14:26:27

标签: android andengine tiles

我正在使用平铺为我的游戏创建地图。我正在使用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)

1 个答案:

答案 0 :(得分:0)

看起来你的TMX文件中的文件路径有问题。有关详细信息,请参阅AndEngine论坛上的thisthis主题。