首页 > 移动平台 > 详细

摄像机跟随主角移动

时间:2017-01-09 13:19:44      阅读:288      评论:0      收藏:0      [点我收藏+]
  1. void MPlayer::setMapPointByMplayer()
  2. {
  3. Size visableSize = Director::getInstance()->getVisibleSize();
  4. Size mapTileNum = getGameMap()->getMapSize();
  5. Size tiledSize = getGameMap()->getTileSize();
  6. //世界大小 2.x CCSizeMake
  7. Size mapSize = Size(mapTileNum.width * tiledSize.width, mapTileNum.height * tiledSize.height);
  8. Point mplayerPoint = mSprite->getPosition();
  9. float x = mplayerPoint.x > visableSize.width / 4 ? mplayerPoint.x : visableSize.width / 4;
  10. x = x < mapSize.width - visableSize.width*.8 ? x : mapSize.width - visableSize.width*.8;
  11. float j = mapSize.width - visableSize.width*0.8;
  12. float y = mplayerPoint.y > visableSize.height / 4 ? mplayerPoint.y : visableSize.height / 4;
  13. y = y < mapSize.height / 2 ? y : mapSize.height / 2;
  14. Point desPoint = ccp(x, y);//目标点
  15. Point centerPoint = ccp(visableSize.width / 5, visableSize.height / 4);
  16. Point ritPoint = ccpSub(centerPoint, desPoint);
  17. getGameMap()->setPosition(ritPoint);
  18. }





摄像机跟随主角移动

原文:http://www.cnblogs.com/feizuzu/p/859bf3bd096bd123c891047da4f79da9.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!