0

我可以使用这种方法(如何在 Cocos2d-X 中的 CCSprite 对象中交换精灵)为 CCSprite 类交换一个精灵。但是,CCScale9Sprite 类似乎不允许这样做,因为该类不存在 setTexture 方法。

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

4

1 回答 1

0

好的,看来我在“highlight_button”方法下使用这些行得到了这份工作:

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

“unhighlight_button”方法的类似方法。

于 2013-11-11T16:16:22.003 回答