cocos2dx-让CCLayer随着英雄移动而移动

来源:互联网 发布:ajax和php实现文件上传 编辑:程序博客网 时间:2024/05/16 09:46
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);}

原创粉丝点击