zoukankan      html  css  js  c++  java
  • 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函数, 否则会导致显示不正确.

  • 相关阅读:
    第一次冲刺6
    人机交互课下作业
    第一次冲刺5
    第一次冲刺4
    第一次冲刺3
    第一次冲刺2
    第一次冲刺
    典型用户分析
    掌握 需求过程阅读笔记02
    掌握 需求过程阅读笔记01
  • 原文地址:https://www.cnblogs.com/moodlxs/p/2834246.html
Copyright © 2011-2022 走看看