cocos2dx button的使用以及cocostudio/ObjectFactory.h: No such file or directory错误解决方案
来源:互联网 发布:天浩网络打印服务器 编辑:程序博客网 时间:2024/05/22 14:50
上一篇博客里面讲过menu,在跟玩家交互的过程中,我们有些时候也需要使用到一些独立的button,cocos2dx中也有相应的button的控件可以使用,下面我们来看看如何进行使用。
首选需要包含所需要的头文件:
#include "ui/CocosGUI.h"
然后为了使用方便,我们设置一下命名空间:
using namespace ui;接下来我们来创建一个简单的button:
首先我们看官方文档:
http://cn.cocos2d-x.org/doc/cocos2d-x-3.0/d2/db1/classcocos2d_1_1ui_1_1_button.html#adf271b1be4c753b7f9ddf23e8f67c530
static Button* create(const std::string & normalImage,const std::string & selectedImage = "",const std::string & disableImage = "",TextureResType texType = TextureResType::LOCAL )
这是button的create函数,我们可以看到,第一个参数是未被选中时的纹理,第二个是被选中时的纹理,第三个是不可备选的纹理。这里只有第一个参数是必须的,后面的都有默认值,那么我们创建一个简单的:
auto btn0 = Button::create("test.png");
因为button是继承与node,所以一些set***的函数都可以使用,日入setScale,setPosition等等。此外还可以给button绑定事件监听函数,这些内容大家随便百度一下就能找到,这里要着重说明的一个问题是在使用button的时候很多人都遇到一个问题:
就是在编译链接的时候cocostudio/ObjectFactory.h: No such file or directory出现这个错误,这个错误的原因其实是因为在项目自动生成的时候,不会去链入ui相关的lib,所以需要手动添加,很简单,将Android.mk中的:
LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static$(call import-module,editor-support/cocostudio)这两行的注释去掉即可。这个错误也是困扰我近一个晚上的错误,win平台下可以通过导入项目lib来fix。
0 0
- cocos2dx button的使用以及cocostudio/ObjectFactory.h: No such file or directory错误解决方案
- fatal error: cocostudio/CocoStudio.h: No such file or directory
- Linux错误 curses.h:No such file or directory解决方案
- gnutls.h: No such file or directory 的解决方案
- 安装tinyos后,出现Python.h:No such file or directory错误的解决方案
- 出现Python.h:No such file or directory错误的解决方案
- docker "no such file or directory"错误的一个解决方案
- cocos2dx 3.1.1 box2d.h : No such file or directory
- cocos2d-x3.2中fatal error: cocostudio/CocoStudio.h: No such file or directory
- Cocos2dx3.0 疑难解答系列 (二) 编译android时,报 CocoStudio.h no such file or directory等类似错误
- fatal error:xxx.h no such file or directory 解决方案
- 在Ubuntu16.04里面安装 pycurl 提示错误的问题:gnutls.h: No such file or directory 的解决方案
- linux/videodev.h: No such file or directory错误解决方法
- Libxml/tree.h:No such file or directory错误
- 错误:ui_mainwindow.h:No such file or directory
- mysql错误:my_config.h: No such file or directory
- Libxml/tree.h:No such file or directory错误
- redis 安装错误 jemalloc.h: No such file or directory
- Google Play Services
- 关于HTML5的画布canvas
- 程序员必读书籍及导读指南
- 广义线性模型
- 【控件篇】ProgressBar+ProgressDialog使用案例
- cocos2dx button的使用以及cocostudio/ObjectFactory.h: No such file or directory错误解决方案
- HDU_1075_What Are You Talking About(字典树)
- softmax回归
- iOS笔记3
- Odoo(OpenERP)开发实践:在QWeb报表中自定义页眉页脚
- 20150327上班第一天
- 非负矩阵分解(NMF)
- atitit.科技公司的超级武器--超级框架,到底要不要自己的框架??
- dojo bootstrap的使用