【发布时间】:2013-01-07 06:24:31
【问题描述】:
我的游戏有问题。我有一张 1280x1280px 的地图。它由 40x40 块组成,因此 1 个块是 32x32 像素。问题是我无法将此地图缩放到设备的实际屏幕尺寸。有什么办法吗?
这是我加载 tmx 文件的方式:
public Scene onLoadScene() {
// TODO Auto-generated method stub
this.mMainScene = new Scene(1);
try
{
final TMXLoader tmxLoader = new TMXLoader(this, this.mEngine.getTextureManager(),
TextureOptions.BILINEAR_PREMULTIPLYALPHA);
this.mTMXTiledMap = tmxLoader.loadFromAsset(this,"gfx/untitled.tmx");
//"gfx/0_fire_drill-lvl_01.tmx"
}
catch(final TMXLoadException tmxle)
{
Debug.e(tmxle);
}
for(TMXLayer tmxLayer : this.mTMXTiledMap.getTMXLayers())
{
this.mMainScene.getChild(0).attachChild(tmxLayer);
}
return this.mMainScene;
}
地图是这样的: http://postimage.org/image/403w3dfnx/
动作只会发生在红色区域。 我需要编辑地图吗?
提前谢谢你!
【问题讨论】:
-
你不缩放,你必须修改相机对象来调整你的视口
-
我应该用 mCamera.setCenter() 来做吗?还是有其他功能?
-
初始化相机时{例如new Camera(px,py,width,height)}你定义相机的宽高。 px 和 py 是偏移量。如果您使用 1280 1280 值,您将看到整个地图,如果您使用较小的值,您将看到地图的一部分,请使用这些值来获得所需的视口。
标签: android map scale andengine tmx