问答详情
源自:2-3 开始界面

图片没有覆盖全屏???怎么办

求解求解求解

提问者:铃兰萤梦 2017-04-21 14:56

个回答

  • wyt1996
    2017-12-08 14:33:37
    已采纳

    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);

    }


  • qq_岛是海心上的疤_4
    2018-12-23 23:21:18

    非常感谢