所有testcpp里的widget示例都已实现,实现了一个GuiExample,其他的就留给大家去熟悉.其实无非就是将c代码拷贝到lua里然后修改一点...
代码,pkg和示例
使用步骤:
1.解压下载包
2.将extensions下的Cocostudio/GUI文件夹备份,然后用解压的GUI文件夹覆盖原文件夹
3.将tools/tolua++文件夹备份,将pkg.zip解压到tools/tolua++下,然后运行命令行编译出LuaCocos2d.cpp(这步编译不会的...去百度)
4.编译cocos2d-x工程,就可以在lua里使用Cocostudio的GUI里的类了
使用Hellolua工程跑示例程序:
将bin下面的所有文件夹和lua拷贝到samples\Lua\HelloLua\Resources下
将hellolua项目里的AppDelegate.cpp的函数applicationDidFinishLaunching()修改一下
bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(CCEGLView::sharedOpenGLView()); CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionNoBorder); // turn on display FPS pDirector->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // register lua engine CCLuaEngine* pEngine = CCLuaEngine::defaultEngine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("hellogui.lua"); pEngine->executeScriptFile(path.c_str()); return true; }
lua中UIWidget注册回调函数的方法
UIWidget :registerEventScript
lua回调示例这样 (这里和v2.1.5不一样,多返回了一个调用者的UIWidget类型的指针)
function HandleEvent(type,widget) if type == "pushDown" then -- do something end end
现有eventType为
"pushDown"
"move"
"releaseUp"
"cancelUp"
"longClick" (这个studio还未实现)
"selected"
"unSelected"
"percentChanged"
"attachWithIME"
"detachWithIME"
"insertText"
"deleteBackward"
"berthToLeftBottom"
"berthToLeftTop"
"berthToRightBottom"
"berthToRightTop"
"berthToLeft"
"berthToTop"
"berthToRight"
"berthToBottom"
"bounceOver"
"bounceToLeftBottom"
"bounceToLeftTop"
"bounceToRightBottom"
"bounceToRightTop"
"bounceToLeft"
"bounceToTop"
"bounceToRight"
"bounceToBottom"
"initChild"
"updateChild"
"scrollToTop"
"scrollToBottom"
"scrollToLeft"
"scrollToRight"
增加CCSSceneReader绑定
CCSceneReader补丁pkg
使用方法:
1.先备份tools/tolua++文件夹然后将补丁解压到tools/tolua++下
2.运行命令行编译出LuaCocos2d.cpp
3.将工作项目链接pthreadVCE2.lib和libchipmunk.lib库,编译即可
同事完成了完整示例,在此放上
ccs完整示例
如果有问题,可以在这个群里找到我,群号:150623497,@我会活得很好.加好友就算了...已经加不下了