Is this a BUG? contentSize maintains after setScale()

Simple code:

    CCSprite* pSprite = CCSprite::create("HelloWorld.png");
    pSprite->setPosition( ccp(size.width/2, size.height/2) );
    CCLog("BEFORE contentSize: (%f, %f)", pSprite->getContentSize().width, pSprite->getContentSize().height);
    pSprite->setScale(0.5f);
    CCLog("AFTER  contentSize: (%f, %f)", pSprite->getContentSize().width, pSprite->getContentSize().height);

And here’s the log result:

    BEFORE contentSize: (480.000000, 320.000000)
    AFTER  contentSize: (480.000000, 320.000000)

It seems that the content size of a CCSprite remains the same even after change its scale. So whether it’s a bug or not?

2 Likes

Hi, it’s not a bug, you should multiply the scale. :slight_smile:

Three years later, I still run into this constantly. Maybe it’s worth having a convenient scaledContentSize?

1 Like