【问题标题】:How to change a sprite using CCScale9Sprite object如何使用 CCScale9Sprite 对象更改精灵
【发布时间】:2013-11-11 14:50:45
【问题描述】:

我可以使用这种方法 (How to swap the sprite in the CCSprite object in Cocos2d-X) 为 CCSprite 类交换一个精灵。但是,CCScale9Sprite 类似乎不允许这样做,因为该类不存在 setTexture 方法。

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

【问题讨论】:

    标签: cocos2d-x ccsprite


    【解决方案1】:

    好的,看来我在“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”方法的类似方法。

    【讨论】:

      猜你喜欢
      • 2018-03-08
      • 1970-01-01
      • 1970-01-01
      • 2012-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 2019-03-21
      相关资源
      最近更新 更多