铃兰萤梦
2017-04-21 14:56
求解求解求解
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);
}
非常感谢
新春特辑-Cocos抢红包
21913 学习 · 16 问题
相似问题