求解求解求解
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);
}
非常感谢