The camera follows the lead and moves

Source: Internet
Author: User

  
 
  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 = size ( maptilenum width * Tiledsize width Maptilenum height * Tiledsize height
  8. point = Msprite -> Span class= "PLN" >getposition ();
  9. float = 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 = mapsize width - Visablesize width * 0.8
  12. float = Mplayerpoint y > Visablesize height / 4 Mplayerpoint y : Visablesize height / 4 ;
  13. y = < mapsize height / 2 y : Mapsize height / 2 ;
  14. point = CCP ( x y //target point
  15. Point centerPoint = ccp(visableSize.width / 5, visableSize.height / 4);
  16. Point ritPoint = ccpSub(centerPoint, desPoint);
  17. getGameMap()->setPosition(ritPoint);
  18. }



From for notes (Wiz)

The camera follows the lead and moves

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.