• cocos2dx CCControlButton用法


        CCScale9Sprite *backgroundButton = CCScale9Sprite::create(btnImg, imgRect, imgRectInsets);
        CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create(hightLightBtnImg, imgRect, imgRectInsets);
        m_button = CCControlButton::create(backgroundButton);
        m_button->setZoomOnTouchDown(false); //设置不现实按钮效果
        m_button->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
        m_button->setPreferredSize(CCSizeMake(size.height, size.height));
        //m_button->setContentSize(CCSizeMake(size.height, size.height));
        m_button->setPosition(m_label->getContentSize().width + m_button->getContentSize().width/2, m_button->getContentSize().height/2);
        addChild(m_button, 1);

    需要注意的是注释的

    m_button->setContentSize(CCSizeMake(size.height, size.height));

    这句,调整CCControlButton的大小不能用setContentSize, 只能setPreferredSize函数, 否则会导致显示不正确.

  • 相关阅读:
    POJ 2386 Lake Counting
    POJ 1852 Ants
    HDU 4570 Multi-bit Trie
    HDU 4611 Balls Rearrangement
    ZOJ 3551 Bloodsucker
    HEU 百题解1001 谁是中间的那个
    BNU 1001 北师大ACM新手指导/ICPC introduction(1)
    BOJ 1580 Shoot
    BOJ 1578 Maximum
    BOJ 1577 Easy Game
  • 原文地址:https://www.cnblogs.com/moodlxs/p/2834246.html
Copyright © 2020-2023  润新知