2.x时代的CCControlButton的确十分方便,策划们也十分喜欢按下有缩放的效果

到了3.x的项目,工具链已经相当完善,我使用的是cocos2dx3.2+quick3.2rc1+cocos code ide 1.0.1+cocos studio 1.6(以下简称ccs)

在ccs里建立的按钮,到了程序里实际上是UIPushButton

从quick的源码可以看出,UIPushButton继承于UIButton,UIButton继承于cc.Node

那么按下弹起的效果就得自己写了,好在quick扩展的方式很方便

我用起来是全局的

在载入ccs之后,会遍历所有节点,找出node.__cname == “UIPushButton”的元素,然后UIButtonEx.extend(node); node:setPressedActionEnabled(true)就可以了

需要按钮放大的,把0.9改成1.1就行了

2 thoughts on “[quick3.x]UIButton按下弹起的缩放效果扩展

  1. 请问能够详细解释一下,如何使用吗?最后一句没看懂
    “在载入ccs之后,会遍历所有节点,找出node.__cname == “UIPushButton”的元素” 这句话什么意思啊?

    Reply
    • 用getChildren()拿到childrenList getChildrenCount()得到children数量

      然后遍历childrenList 每个元素里有个属性叫__cname

      Reply

Leave a reply to superyyl 取消回复

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url=""> 

required