سؤال

I'm trying to get window size, but I'm getting the wrong position.

I'm getting the size with this:

Size visibleSize = Director::getInstance()->getWinSize();

But, when I try to use visibleSize.width/2 and .height/2 the sprite doesn't appear in the center of the screen.

هل كانت مفيدة؟

المحلول

Try explicitly setting the anchor point of the sprite to the middle of the sprite.

sprite->setAnchorPoint(Point(0.5, 0.5))

http://www.cocos2d-x.org/wiki/Coordinate_System

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top