【发布时间】:2013-11-11 14:50:45
【问题描述】:
我可以使用这种方法 (How to swap the sprite in the CCSprite object in Cocos2d-X) 为 CCSprite 类交换一个精灵。但是,CCScale9Sprite 类似乎不允许这样做,因为该类不存在 setTexture 方法。
我在我的菜单中使用了 9patch 按钮,我想适当地更改精灵的触摸/非触摸动作。有什么建议吗?
【问题讨论】:
我可以使用这种方法 (How to swap the sprite in the CCSprite object in Cocos2d-X) 为 CCSprite 类交换一个精灵。但是,CCScale9Sprite 类似乎不允许这样做,因为该类不存在 setTexture 方法。
我在我的菜单中使用了 9patch 按钮,我想适当地更改精灵的触摸/非触摸动作。有什么建议吗?
【问题讨论】:
好的,看来我在“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”方法的类似方法。
【讨论】: