【问题标题】:frame set on renderTexture in Cocos2D在 Cocos2D 中的 renderTexture 上设置的框架
【发布时间】:2012-05-30 18:46:51
【问题描述】:

我是 cocos2D 的新手,我想在其中画线,我尝试从 here 实现它

我在其中设置的框架有问题。我通过下面的代码设置背景图片

CCSprite* 背景 = [CCSprite spriteWithFile:imgPath rect:frame];

其中 imgPath 是设置为 CCSprite 的图像文件的路径,而 frame 是视图边界。 CCSprite的框架没问题,现在我加了

  [background addChild: [LineDrawingClass node]];

然后我使用以下代码片段将 CCRenderTexture 实例添加到 LineDrawingClass

renderTexture.anchorPoint = ccp(0, 0);
renderTexture.position = ccp(self.width * 0.5f, self.height * 0.5f);

然后我将 renderTexture 添加到 LineDrawingClass

我得到的是 CCSprite 的背景设置为正确的帧,没有问题,但 renderTexture 的帧设置在 CCSprite 下方大约五个像素。

我还将锚点设置为

renderTexture.anchorPoint = ccp(0.5f, 0.5f);

但是 renderTexture 在 origin.y 中的滞后仍然存在。

请参阅附图以供参考。有人能指出错误并纠正我,renderTexture 的帧正好超过 CCSprite 的帧(现在与 origin.y 有 5px 的滞后)?

【问题讨论】:

  • 我反复听说 CCRenderTexture 存在一些偏移问题。据我所知,这看起来是 cocos2d 中的一个错误。

标签: ipad cocos2d-iphone


【解决方案1】:

尝试将纹理的高度设置得稍大一些,如果 480 是您的高度,请将其设置为 580 或更大,以符合您的要求。

renderTexture.position = ccp(self.width * 0.5f, (self.height + 100) * 0.5f);

这是因为一些方向问题。

【讨论】:

    猜你喜欢
    • 2014-09-12
    • 1970-01-01
    • 2014-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多