Cocos2d-x版本2.2 CCRenderTexture无法在Samsung Tab 4(型号SMT231)上正确渲染图像

时间:2015-01-07 11:33:36

标签: cocos2d-x

我一直试图使用渲染纹理绘制移动的触摸。这是我的代码:

void GameplayLayer::visitSpriteContinuously()
{
   CCRenderTexture*    canvas = CCRenderTexture::create(screenSize.width,screenSize.height,kCCTexture2DPixelFormat_RGBA4444);

   canvas->setPosition(ccp(screenSize.width/2,screenSize.height/2));
   this->addChild(canvas);

   GameSprite* drawSprite=GameSprite::gameSpriteWithFile(“circle.png");
   this->addChild(drawSprite);

   CCPoint start = starttouchPosition->getLocationInView();
   start = CCDirector::sharedDirector()->convertToGL(start);

CCPoint end = starttouchPosition -> getPreviousLocationInView();
end = CCDirector::sharedDirector()->convertToGL(end);

float distance = ccpDistance(start, end);
canvas->begin();
for (int i = distance; i > 0; i--)
{
    float difx = end.x - start.x;
    float dify = end.y - start.y;
    float delta = (float)i / distance;
    drawSprite->setPosition(ccp(start.x + (difx * delta), start.y + (dify * delta)));
    drawSprite->visit();
}
canvas->end();

}

我在几乎所有测试过的Android设备上都得到了理想的结果,除了三星Tab 4.在Tab 4上,即使使用的基本png图像是单纯色,绘制的精灵也有点状图案。我搜索了很多,但我找不到任何有用的东西。如果有人遇到类似问题并有解决方案,请告诉我。以下是截图:

'A'在其他设备上呈现: Other Devices:

三星标签4上呈现的'p''A': Samsung Tab 4

1 个答案:

答案 0 :(得分:0)

在某些设备中,RGBA4444格式不能正确支持,因此在这种情况下,您必须使用RGBA8888格式。 所以,只需在代码中更改此行

即可
CCRenderTexture*    canvas = CCRenderTexture::create(screenSize.width,screenSize.height,kCCTexture2DPixelFormat_RGBA4444);

CCRenderTexture*    canvas = CCRenderTexture::create(screenSize.width,screenSize.height,kCCTexture2DPixelFormat_RGBA8888);