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);
}

posted on 2013-03-17 14:28  纯洁的坏蛋  阅读(204)  评论(0编辑  收藏  举报