void HelloWorld::setCenterOfScreen(CCPoint p)
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
int x = MAX(p.x, s.width / 2);
int y = MAX(p.y, s.height / 2);
x = min(x, map->getMapSize().width * map->getTileSize().width - s.width/2);
y = min(y, map->getMapSize().height * map->getTileSize().height - s.height/2);
CCPoint goodPoint = ccp(x, y);
CCPoint centerOfScreen = ccp(s.width/2, s.height/2);
CCPoint diffence = ccpSub(centerOfScreen, goodPoint);
this->setPosition(diffence);
}
cocos2dx-让CCLayer随着英雄移动而移动
最新推荐文章于 2024-04-27 10:55:31 发布