Bug about CCScale9Sprite in new version

思远 陈Wei-Sung Yeh
@Dai tianqi

I cannot reproduce the crash you mentioned. After my latest update (which I have submitted a pull request for) my tests with a spritesheet are working ok for both non-rotated and rotated sprites.

If you still see a crash, please paste the spritesheet you are using so I can debug.

Thanks.

Do the bug still persist?

Should I use master version instead of 2.1beta?

The only workaround I find is to set Algorithm to “Basic” in TexturePacker.

Do the bug still persist?
>
Should I use master version instead of 2.1beta?

My changes have been pushed to master.

>

The only workaround I find is to set Algorithm to “Basic” in TexturePacker.

Could you please try setting the “Trim” option to “None”?

Thanks.

I have set Trim to None with version 2.1-beta3-x-2.1.1 —- Still the same.

I have downloaded Master and also the problem persist (bottom right of my last post screenshot).

I’ve attached the sheet here, and also here’s sample code to test it inside a CCLayer:

NOTE: Extract the zip in /Resources

CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFrames();
CCSpriteBatchNode* menuElementsBatchNode = CCSpriteBatchNode::create("sd/MenuScene/menuElements.pvr.ccz");
this->addChild(menuElementsBatchNode, 0);
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("sd/MenuScene/menuElements.plist");


CCScale9Sprite* menuButton = CCScale9Sprite::createWithSpriteFrameName("menuButtonBottom.png",CCRectMake(5,5,8,8));
menuButton->setContentSize(CCSizeMake(winSize.width-20, 67));
CCScale9Sprite* menuButtonP = CCScale9Sprite::createWithSpriteFrameName("menuButtonBottomP.png",CCRectMake(5,5,8,8));
menuButtonP->setContentSize(CCSizeMake(winSize.width-20, 67));
CCScale9Sprite* menuButtonP2 = CCScale9Sprite::createWithSpriteFrameName("menuButtonBottomP.png",CCRectMake(5,5,8,8));
menuButtonP->setContentSize(CCSizeMake(winSize.width-20, 67));
item = CCMenuItemSprite::create(menuButton, menuButtonP,menuButtonP2, 
    this, menu_selector(MenuScene::menuCallback1)); 

CCMenu menu = MenuPanel::create();
menu ->addChild(item);

this->addChild(menu);

Until this is fixed I think I’m gonna save time setting the algorithm to “Basic” on TexturePacker. That way, the sprites won’t be rotated.

Thanks danadn_! I will take a look.

Could you please confirm : did the sprites display correctly with earlier versions of cocos2d-x?
I am trying to find out if we have a regression bug.

I too am experiencing issues with CCScale9Sprites ignoring the trimmed space in a spritesheet. I put together sample code to illustrate (archive is only Classes and Resources folders).

In my investigation, the function CCScale9Sprite::initWithSpriteFrame* callsspriteFrame~~>getRect* to get the texture itself, but never *spriteFrame~~>getOffset()* or *spriteFrame->getOriginalSize()* to rebuild the trimmed empty space.