Question

I'm able to swap a sprite using this method (How to swap the sprite in the CCSprite object in Cocos2d-X) for the class CCSprite. However, it seems not allowed for the CCScale9Sprite class since the setTexture method doesn't exist for this class.

I use a 9patch button in my menu and I'd like to change the sprite suitably touch/untouch actions. Any suggestion?

Was it helpful?

Solution

Ok, it seems I got the job using these lines under the "highlight_button" method:

CCScale9Sprite *pSprite=(CCScale9Sprite *)cell->getChildByTag(789); // Get the sprite from the cell
pSprite->initWithFile("button.png");
pSprite->setContentSize( CCSizeMake(winSize.width, 84) );
pSprite->setAnchorPoint(CCPointZero);
pSprite->setPosition(CCPointZero);

A similar approach for the "unhighlight_button" method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top