简体   繁体   English

Retina显示图像看起来模糊和模糊。 没有理由?

[英]Retina Display images looks fuzzy and blurred. No Reason why?

I am a Cocos2d game developer. 我是Cocos2d游戏开发者。 I am developing a game using retina display images. 我正在使用视网膜显示图像开发游戏。

I have created texture files with and without HD suffix using zwoptex. 我使用zwoptex创建了带有和不带HD后缀的纹理文件。

I have added those zwoptex plist texture files in app-delegate like [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Background.plist"]; 我在app-delegate添加了那些zwoptex plist纹理文件,如[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Background.plist"]; I have enabled the retina display to YES [director enableRetinaDisplay:YES]; 我已将视网膜显示启用为YES [director enableRetinaDisplay:YES]; .

I have used the png files from the plist wherever i want using ccsprite *background = [CCSprite spriteWithSpriteFrameName:@"sample.png"]; 我使用ccsprite *background = [CCSprite spriteWithSpriteFrameName:@"sample.png"];使用plist中的png文件ccsprite *background = [CCSprite spriteWithSpriteFrameName:@"sample.png"]; .

All those png files which I have included are high resolution images with both sizes 960*640 and 480 * 320 . 我所包含的所有png文件都是高分辨率图像,尺寸分别为960*640480 * 320 But in no reason the images look blurry and fuzzy when i run the game in simulator or iPhone. 但是当我在模拟器或iPhone中运行游戏时,图像看起来没有任何理由模糊和模糊。 Anyone please help me to solve this issue ….. 有人请帮我解决这个问题......

(The following image was posted as an example in a comment.) (以下图片在评论中作为示例发布。)

在此输入图像描述

cocos2d applies anti-aliasing to sprites by default. 默认情况下,cocos2d对sprite应用消除锯齿功能。 You need to turn that off: 你需要关闭它:

[background.texture setAliasTexParameters];

hope this helps. 希望这可以帮助。

The screenshot you posted (I took the liberty of adding it to your question) shows that it was taken from the iPhone Simulator and not the iPhone (Retina) Simulator. 您发布的屏幕截图(我冒昧地将其添加到您的问题中)显示它是从iPhone模拟器而不是iPhone(Retina)模拟器中获取的。 Therefore it will not use the HD images. 因此它不会使用高清图像。

With the iPhone Simulator running go to the Hardware -> Device menu and select iPhone (Retina) as the device. 运行iPhone模拟器后,转到硬件 - >设备菜单,然后选择iPhone(Retina)作为设备。 Then restart your app. 然后重启你的应用。

Note also that the iPhone Simulator will only render the game with a color depth of 16-Bit, regardless of settings in cocos2d or your Mac. 另请注意,无论cocos2d或Mac中的设置如何,iPhone模拟器都只会渲染颜色深度为16位的游戏。 The iOS Simulator renderer is limited to 16-Bit rendering for performance reasons (it only uses software rendering, no hardware acceleration). 出于性能原因,iOS模拟器渲染器仅限于16位渲染(它仅使用软件渲染,无硬件加速)。 Only by looking at the game on an actual device can you make judgement calls about image quality. 只有通过在实际设备上查看游戏,您才能对图像质量做出判断。

To test whether the game is actually loading the HD assets or for some reason just loads the SD images, try running it without the SD images. 要测试游戏是否实际加载高清资产或出于某种原因只加载SD图像,尝试在没有SD图像的情况下运行它。 If the game tries to load the SD images it will cause an error. 如果游戏试图加载SD图像,则会导致错误。 If not, it is loading the HD images and the "blur issue" has a different cause. 如果没有,它正在加载高清图像,“模糊问题”有不同的原因。 You could also log which files are loaded by adding a NSLog statement to the CCFileUtil class method fullPathFromRelativePath which performs the file name changes to load -hd images whenever possible. 您还可以通过向CCFileUtil类方法fullPathFromRelativePath添加NSLog语句来记录加载的文件,该方法执行文件名更改以尽可能加载-hd图像。

You'll find that even miniscule amount of scaling or rotation applied to a sprite may have it look blurred, so check if you happen to do that. 您会发现,即使应用于精灵的微小量缩放或旋转也可能使其看起来模糊,因此请检查您是否碰巧这样做。 Any change in blend modes (using ccBlendFunc) could also cause blurred images. 混合模式的任何更改(使用ccBlendFunc)也可能导致图像模糊。 Also check that your images are fully opaque (opacity == 255). 还要检查图像是否完全不透明(不透明度== 255)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM