CCControlButton使用时发现的点击范围问题(只能在右下角点击按键)
2013-04-02 09:25
483 查看
比如以下代码
此代码编译过去后,会出现只能点击右下角的才能按键响应,经过查找学习发现在m_button中多加这句
及可以正常点击按键范围,不过setPreferredSize在代码提示不出来,不知道大家的版本会不会提示出来咯
CCRect rect = CCRectMake(0,0,0,0); CCRect rectInsets = CCRectMake(0,0,1,1);
CCScale9Sprite *backgroundButton = CCScale9Sprite::create("Icon.png",rect,rectInsets); CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("Icon.png",rect,rectInsets); CCSize size=backgroundButton->getContentSize(); CCControlButton *m_button = CCControlButton::create(backgroundButton); m_button->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted); m_button->setPosition(200,200); addChild(m_button, 1);
此代码编译过去后,会出现只能点击右下角的才能按键响应,经过查找学习发现在m_button中多加这句
m_button->setPreferredSize(CCSizeMake(size.width, size.height));
及可以正常点击按键范围,不过setPreferredSize在代码提示不出来,不知道大家的版本会不会提示出来咯
相关文章推荐
- 【Cocos2dx】使用CCControlButton创建按钮、按钮点击事件,点击事件中的组件获取,setPosition的坐标问题
- cocos2d-x使用CCControlButton的一些问题
- 12.解决CCScale9Sprite或者CCControlButton无法使用的问题。
- CCControlButton的使用
- 使用xbmc/kodi作为dlna render设备时,连接到某些wifi热点/路由器上,不能被dlna control找到发现的问题——原因是WIFI模组深度优化后,从省电模式唤醒时,会丢失组播包
- cocos2d-x tableview和CCControlButton的使用
- cocos2d-x tableview和CCControlButton的使用
- cocos2d-x tableview和CCControlButton的使用
- GridView中使用类似于Button btnToped = (Button)e.Row.FindControl("btnToped");提示“未将对象引用到实例”,也就是找不到控件的问题的解决方法
- CCControlButton的使用
- cocos2d-x 常用代码、高频使用代码【CCLayer、CCEditBox编辑框、CCControlButton按钮、CCLabelTTF标签、CCSpriteBatchNode渲染、CCMen】
- cocos2d-x控件使用CCControlButton<代码演示>
- vs2012 cocos2dx中CCControlButton绑定点击事件无回调
- CCControlButton的使用
- 【Cocos2d-x】CCControlButton状态按钮的使用
- CCControlButton的使用
- IOS 百度地图使用问题(同一个标注只能点击一次)
- 9、Cocos2d-X 游戏编程之------CCControlButton的使用
- 避免用户重复点击按钮(使用Enable:=False,消息繁忙时会有堵塞的问题,只能改用Sleep)
- chrome下form内的button的第一次点击问题的发现