cocos2d-x图层相关 锚点

时间:2020-12-24 00:39:50

CCLayerColor* ccc = CCLayerColor::create(ccc4(255,0,0,255));
ccc->setContentSize(CCSize(200,200));
CCLog("anchor<<%f<<%f",ccc->getAnchorPoint().x,ccc->getAnchorPoint().y);
ccc->ignoreAnchorPointForPosition(false);//设置false后有效
ccc->setPosition(ccp(getContentSize().width/2,getContentSize().height/2));
this->addChild(ccc);

CCSprite* sp = CCSprite::create("CloseNormal.png");
sp->setPosition(ccp(10,10));

ccc->addChild(sp);

运行效果:

cocos2d-x图层相关 锚点