Skip to content

Instantly share code, notes, and snippets.

@indatawetrust
Created May 19, 2016 11:24
Show Gist options
  • Save indatawetrust/d04611d445a4ef7fc53cec3d038c3913 to your computer and use it in GitHub Desktop.
Save indatawetrust/d04611d445a4ef7fc53cec3d038c3913 to your computer and use it in GitHub Desktop.
cocos2d-x sprite center position
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
auto sprite = Sprite::create("ball.png");
sprite->setPosition(Vec2(visibleSize.width / 2 + origin.x,
visibleSize.height / 2 + origin.y));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment