Cocos2d x 如何使用CCScale9Sprite对象更改精灵

Cocos2d x 如何使用CCScale9Sprite对象更改精灵,cocos2d-x,ccsprite,Cocos2d X,Ccsprite,我能够使用这个方法()将一个精灵替换为类CCSprite。但是,CCScale9Sprite类似乎不允许这样做,因为该类不存在setTexture方法 我在菜单中使用了一个9patch按钮,我想适当地更改sprite触摸/非触摸操作。有什么建议吗?好的,我似乎是通过“突出显示按钮”的方法得到了这份工作: “取消高亮按钮”方法的类似方法 CCScale9Sprite *pSprite=(CCScale9Sprite *)cell->getChildByTag(789); // Get the

我能够使用这个方法()将一个精灵替换为类CCSprite。但是,CCScale9Sprite类似乎不允许这样做,因为该类不存在setTexture方法


我在菜单中使用了一个9patch按钮,我想适当地更改sprite触摸/非触摸操作。有什么建议吗?

好的,我似乎是通过“突出显示按钮”的方法得到了这份工作:

“取消高亮按钮”方法的类似方法

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