cocos2dx笛卡尔坐标

前端之家收集整理的这篇文章主要介绍了cocos2dx笛卡尔坐标前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
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,1.0));


//点
auto dot = DrawNode::create();
dot->drawDot(Vec2(0,10,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;

}

原文链接:https://www.f2er.com/cocos2dx/342331.html

猜你在找的Cocos2d-x相关文章