COCOS2D-X: scale sprite

后端 未结 3 2028
暗喜
暗喜 2021-01-25 11:16

I want to set scale for a sprite by height of original image. And then the width of that sprite will follow by original ratio of that image. How can i do that. Thank for all you

3条回答
  •  遥遥无期
    2021-01-25 11:41

    use setScale function of CCSprite e.g -

    CCSprite *Sprite   =   CCSprite::create(WHEEL_SPRITE);
    Sprite->setScale(DIRECTOR_VISIBLE_HEIGHT*0.65/Sprite->getContentSize().height);
    Sprite->setPosition(ccp(DIRECTOR_VISIBLE_WIDTH/2, DIRECTOR_VISIBLE_HEIGHT/2));
    this->addChild(Sprite);
    

提交回复
热议问题