CCSize size = CCDirector::sharedDirector()->getWinSize();
 CCSprite* pSprite = CCSprite::create("bg.jpg");
 pSprite->setPosition(ccp(size.width/2, size.height/2));
 float winw = size.width; //获取屏幕宽度
 float winh = size.height;//获取屏幕高度

 float spx = pSprite->getTextureRect().getMaxX();
 float spy = pSprite->getTextureRect().getMaxY();

 pSprite->setScaleX(winw/spx); //设置精灵宽度缩放比例
 pSprite->setScaleY(winh/spy);

相关文章:

  • 2022-12-23
  • 2022-01-06
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案