码迷,mamicode.com
首页 > 移动开发 > 详细

摄像机跟随主角移动

时间:2017-01-09 13:20:42      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:erp   cto   size   title   世界   为知笔记   round   enter   ntb   

  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. }





摄像机跟随主角移动

标签:erp   cto   size   title   世界   为知笔记   round   enter   ntb   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!