cocos2dx menu位置计算
发布时间:2020-12-14 20:38:33 所属栏目:百科 来源:网络整理
导读:解释: bool CCMenu::initWithArray(CCArray* pArrayOfItems){ if (CCLayer::init()) { // menu in the center of the screen CCSize s = CCDirector::sharedDirector()-getWinSize(); this-ignoreAnchorPointForPosition(true); setAnchorPoint(ccp(0.5f,0.
解释:
bool CCMenu::initWithArray(CCArray* pArrayOfItems) { if (CCLayer::init()) { // menu in the center of the screen CCSize s = CCDirector::sharedDirector()->getWinSize(); this->ignoreAnchorPointForPosition(true); setAnchorPoint(ccp(0.5f,0.5f)); this->setContentSize(s); setPosition(ccp(s.width/2,s.height/2)); return true; } return false; }menu忽略锚点(相当于以左下角为锚点),而且初始大小为WinSize,位置在屏幕中间。 所以,我们即使设置锚点,也没有用处。但是可以设置位置和大小。 而且不要使用基于menu锚点的坐标计算方法。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |