图片没有覆盖全屏???怎么办
求解求解求解
求解求解求解
2017-04-21
void HelloWorld::setBackGround(const char *filename){
if(backImg == 0){
backImg=Sprite::create(filename);
backImg->setAnchorPoint(Point::ZERO);
backImg->setPosition(Point::ZERO);
Size mywinsize=Director::getInstance()->getWinSize();
float winw = mywinsize.width;
float winh = mywinsize.height;
float spx = backImg->getTextureRect().getMaxX();
float spy = backImg->getTextureRect().getMaxY();
backImg->setScaleX(winw/spx);
backImg->setScaleY(winh/spy);
this->addChild(backImg);
return;
}
backImg->setTexture(filename);
}
举报