I have a problem with rendering CCSprite sprite I noticed that some of my sprites are blurred. It is more visible on device. But I found out, that if the sprite is near the center of the display it is perfect. So blurred are only sprites that are near to edges.
I tried find information about this, but I found only one suggestion for cocos2d-iphone - it’s autoscale parameter of CCDirector::init() method. But there is no such parameter in cocos2d-x.
Thank you very much.
cocos2d-x has its autoscale mechanism, and it’s different between platforms. ( A little ugly, I admit, aha).
A wiki page is here: [[How does cocos2d-x support multi-resolution]]
You situation hasn’t been reported before, so a screenshot or a photo would explain this stuff better. And an unit test, simply hack helloworld to reproduce this bug will be highly recommended!
thanks for answer.
I’ve added the test project (simple with 5 sprites) and two screenshots from the simulator.
It is rather different that I wrote before, because now are blurred sprites in the center (the second image). Zoom the screenshot to perfect view of the defect.
The first image is different. There are blurred sprites at the top and the bottom. Centered one is quite good but not perfect.
I was testing only on ios platform without retina display enabled. I used template from cocos2d-x. I am using XCode4.
I am tracing this bug, but haven’t resolved it.
The bad thing is that, cocos2d-iphone has the same problem. cocos2d-x inherit this bug.
I use cocos2d-iphone 1.0.0-rc3. and translate your code to
#define WIDTH 320
#define HEIGHT 480
CCSprite* sprite1 = [CCSprite spriteWithFile:@"something.png"];
sprite1.position = ccp(WIDTH/2, HEIGHT/2);
CCSprite* sprite2 = [CCSprite spriteWithFile:@"something.png"];
sprite2.position = ccp(WIDTH/2,HEIGHT/4);
CCSprite* sprite3 = [CCSprite spriteWithFile:@"something.png"];
sprite3.position = ccp(WIDTH/2,HEIGHT/4*3);
CCSprite* sprite4 = [CCSprite spriteWithFile:@"something.png"];
sprite4.position = ccp(WIDTH/4,HEIGHT/2);
CCSprite* sprite5 = [CCSprite spriteWithFile:@"something.png"];
sprite5.position = ccp(WIDTH/4*3, HEIGHT/4);
No matter running on iphone3 simulator or ipad simulator, it looks the same as your tiff pictures.
I run it on iphone4, and get the screenshot
do you have any solution to workaround the problem? I do not understand that anybody does not find the same problems before. The behaviour seems to be random
Hi, Jiri, I just learn this from Riq.
- edit ccConfig.h
- #define CC_COCOSNODE_RENDER_SUBPIXEL 0
This will work for you. Have a try!
thanks fo reply. But I think that there is no effect setting CC_COCOSNODE_RENDER_SUBPIXEL to 0
One of my friend met the same problem, and he told me CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D) will fix this, while the default setting is kCCDirectorProjection3D.
thank you very much. It works perfectly now!:)
Hi, sorry to resuscitate this thread, but I think that
only works if the sprite in pixels are even? odd sizes give me blurred images.
I’m doing something wrong? I am using a RenderTexture and sprites from a big texture map.
This is happening on HD for me. The fixes above may help, and try this: add 0.5 or some similar between-1-and-0 value. This is a known issue with the iPhone trying to render halfway between pixels, not just OpenGL. The iOS manuals may provide some help, but I don’t think they’ll provide much for you. In the meantime, try to figure out where/why it’s doing the half-pixel thingy and adjust the scale/width/size