标签:
bool HelloWorld::init()
{
//////////////////////////////
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
//正方形
auto rect=DrawNode::create();
rect->drawRect(Vec2(0,0),Vec2(300,300),Color4F(1.0,0,0,1.0));
//点
auto dot=DrawNode::create();
dot->drawDot(Vec2(0,0),10,Color4F(1.0,1.0,1.0,1.0));
addChild(rect);
rect->addChild(dot);
rect->setPosition(visibleSize/2);
dot->setPosition(Vec2(10,10));//本地空间
rect->setContentSize(Size(300,300));
rect->setAnchorPoint(Vec2(0.5,0.5));
schedule([dot,rect](float f){
rect->setRotation(rect->getRotation()+1);
auto p=dot->convertToWorldSpace(Vec2(0,0));
CCLOG("%f,%f",p.x,p.y);
},"Test");
return true;
}
标签:
原文地址:http://www.cnblogs.com/daochong/p/5225798.html