RenderTexture 添加子节点坐标的bug

m_render = RenderTexture::create(normalSprite->getBoundingBox().size.width /2, normalSprite->getBoundingBox().size.height / 2, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8);
m_render->setPosition(Vec2(normalSprite->getBoundingBox().size.width / 2, normalSprite->getBoundingBox().size.height / 2));
m_render->clear(0, 0, 0, 0.7f);
m_render->setAutoDraw(true);
addChild(m_render);

this->centerOnPoint(CCPoint(normalSprite->getBoundingBox().getMidX(), normalSprite->getBoundingBox().getMidY()), 1);

auto vmap = DataCenter::GetInstance()->GetValueMap("yhcinfo");
mapLayer::initNodeWithConfig(vmap);

auto paddleTexture = Director::getInstance()->getTextureCache()->addImage("logo.png");
auto aaaa = CCSprite::createWithTexture(paddleTexture);
aaaa->setPosition(Vec2(-100, -100));

m_render->addChild(aaaa);

打开m_render->setAutoDraw(true);自动刷新子节点;
aaaa 的坐标处于比较混乱的状态,移动一个1.0f距离,
相当于父节点的2倍,0,0原点位置在上边界的中心位置

aaaa 的坐标处于比较混乱的状态,移动一个1.0f距离,
相当于父节点的2倍,0,0原点位置在上边界的中心位置

aaaa 比setPosition(-100, -100) 多移动了一个 1.0f的距离?

不是的。
这个父节点是一个可移动的节点,
父节点移动0.5个距离aaaa 会移动大概1.0f的距离
正常的子节点应该是和父节点一样的移动。

你使用的是cocos2d-x的哪个版本?

是3.10官网的版本,大概两个星期前下载的

#include “HelloWorldScene.h”
#include “cocostudio/CocoStudio.h”
#include “ui/CocosGUI.h”

USING_NS_CC;

using namespace cocostudio::timeline;

Scene* HelloWorld::createScene()
{
// ‘scene’ is an autorelease object
auto scene = Scene::create();

// 'layer' is an autorelease object
auto layer = HelloWorld::create();

// add layer as a child to scene
scene->addChild(layer);

// return the scene
return scene;

}

// on “init” you need to initialize your instance
bool HelloWorld::init()
{
Size size = Director::getInstance()->getWinSize();

_render = RenderTexture::create(size.width, size.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8);
_render->setPosition(Vec2(size.width / 2, size.height / 2));
//        _render->setAnchorPoint(Vec2(Vec2::ZERO));
_render->clear(0, 0, 0, 0.7f);
_render->setAutoDraw(true);
addChild(_render);

auto paddleTexture = Director::getInstance()->getTextureCache()->addImage("logo.png");

m_aaaaa = CCSprite::createWithTexture(paddleTexture);
m_aaaaa->setPosition(Vec2(0, 0));

_render->addChild(m_aaaaa);

setTouchEnabled(1);
setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
return true;

}

bool HelloWorld::onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event)
{
_firstTouch = this->convertToNodeSpace(touch->getLocation());
return true;
}
void HelloWorld::onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event)
{

}
void HelloWorld::onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *event)
{

}

void HelloWorld::onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event){

auto pos = this->convertToNodeSpace(touch->getLocation());
pos = ccpSub(pos, _firstTouch);

setPosition(ccpAdd(this->getPosition(), pos));

auto pos2 = ccpSub(this->convertToWorldSpace(_render->getPosition()), _render->convertToWorldSpace(m_aaaaa->getPosition()));

CCLOG("layer poation %f %f m_aaaaa::%f %f ", this->convertToWorldSpace(_render->getPosition()).x, this->convertToWorldSpace(_render->getPosition()).y,
pos2.x, pos2.y);

}

#ifndef HELLOWORLD_SCENE_H
#define HELLOWORLD_SCENE_H

#include “cocos2d.h”

class HelloWorld : public cocos2d::Layer
{
public:
// there’s no ‘id’ in cpp, so we recommend returning the class instance pointer
static cocos2d::Scene* createScene();

// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();

// implement the "static create()" method manually
CREATE_FUNC(HelloWorld);

virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event);
virtual void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event);
virtual void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event);
virtual void onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *event);

cocos2d::CCPoint _firstTouch;

cocos2d::CCSprite* m_aaaaa;
cocos2d::RenderTexture* _render;

};

#endif // HELLOWORLD_SCENE_H

全部测试代码贴出来,
想不出来这个奇葩的增量是哪来的