展会信息港展会大全

cocos2dx menu位置计算
来源:互联网   发布日期:2015-09-28 10:51:50   浏览:1767次  

导读:解释: 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,...

解释:

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锚点的坐标计算方法。

赞助本站

人工智能实验室
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港