简单的镜头跟随

来源:互联网 发布:linux下如何安装输入法 编辑:程序博客网 时间:2024/04/30 15: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);}


0 0