0

I am trying to make a 16 bit style RPG in android using andengine, but I am encountering a major hurdle: the pixels always seem deformed and out of proportion(not squares). This is an issue for text and sprites. Here are the links to the forums that have my issues http://www.andengine.org/forums/post37364.html#p37364 , http://www.andengine.org/forums/post35921.html#p35921 . I am using Nearest as the texture option for both the text and the sprites. My sprites are accessed via texture packer and my text is created using code similar to below

final ITexture mFontInfoTexture = new BitmapTextureAtlas(pContext.getTextureManager(), 256, 256, TextureOptions.NEAREST);

mFontInfo = FontFactory.createFromAsset(pContext.getFontManager(), mFontInfoTexture, pContext.getAssets() , "LongPixelFont.ttf", 18.0f, false, Color.BLACK);
mFontInfo.load();

I've tried scaling the sprite differently, changing the texture option to Linear, shifting the sprite position but nothing really works. Any insight would be greatly appreciated.

UPDATE 1:

This is the code I use that defines the resolution of the app.

    // Initializes the Engine and sets the height and width.
    MainActivity.mMainCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
    //Sets the engine options
    EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), MainActivity.mMainCamera);
    //Forces the screen to go into landscape
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

UPDATE 2:

It seems that the deformation is caused by scaling(for the sprites). I did not notice any deformation when scaling by an int, but when scaling by a fraction there was some deformation. The deformation became more noticeable when scaling by an odd decimal (ie 2.5). It also seems that there is a range where the pixels will look deformed. In my case anything less than 2x will look deformed, but any int above 2 looks fine.

4

2 回答 2

2

您是否考虑过变形可能是由您的比率分辨率策略引起的?如果游戏的纵横比与设备的纵横比不同,某些分辨率策略会拉伸 GL 表面以填满整个屏幕。这肯定会导致非方形像素。

在构建引擎时尝试使用 RatioResolutionPolicy 并查看您的像素现在是否不是方形的。您现在可能会在 yoru 游戏的两侧出现黑条,但如果发生这种情况,您现在就知道问题出在哪里了。

然后,您可以想出一种方法来获取应用程序的全屏大小,并使您的比率分辨率策略完美契合。

== 更新 ==

根据上述评论,您的问题可能与以下内容相同: https ://gamedev.stackexchange.com/questions/19075/how-can-i-make-opengl-textures-scale-without-becoming-blurry

听起来您正在尝试控制 openGL 使用的缩放模式。不幸的是,我不知道在 Andengine 中哪里可以找到这些设置。还有人知道吗?

于 2012-07-24T18:02:35.530 回答
0

尝试将 pAntiAlias 选项从 false 更改为 true。

mFontInfo = FontFactory.createFromAsset(pContext.getFontManager(), mFontInfoTexture, pContext.getAssets() , "LongPixelFont.ttf", 18.0f, true, Color.BLACK);

它应该有助于文本。

于 2012-07-24T17:21:39.777 回答