void MPlayer::setMapPointByMplayer(){ Size visableSize = Director::getInstance()->getVisibleSize(); Size mapTileNum = getGameMap()->getMapSize(); Size tiledSize = getGameMap()->getTileSize(); //世界大小 2.x CCSizeMake Size mapSize = Size(mapTileNum.width * tiledSize.width, mapTileNum.height * tiledSize.height); Point mplayerPoint = mSprite->getPosition(); float x = mplayerPoint.x > visableSize.width / 4 ? mplayerPoint.x : visableSize.width / 4; x = x < mapSize.width - visableSize.width*.8 ? x : mapSize.width - visableSize.width*.8; float j = mapSize.width - visableSize.width*0.8; float y = mplayerPoint.y > visableSize.height / 4 ? mplayerPoint.y : visableSize.height / 4; y = y < mapSize.height / 2 ? y : mapSize.height / 2; Point desPoint = ccp(x, y);//目标点 Point centerPoint = ccp(visableSize.width / 5, visableSize.height / 4); Point ritPoint = ccpSub(centerPoint, desPoint); getGameMap()->setPosition(ritPoint);}