今天的收获,关于hellolua~
来源:互联网 发布:句解霸软件官方下载 编辑:程序博客网 时间:2024/05/20 19:49
1.首先是引擎加载lua的方法,如果要执行lua脚本,直接复制过来就好了
- #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
- CCString* pstrFileContent = CCString::createWithContentsOfFile("helloWorld.lua ");
- if (pstrFileContent)
- {
- pEngine->executeString(pstrFileContent->getCString());
- }
- #else
- std::string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("helloWorld.lua");
- pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
- pEngine->executeScriptFile(path.c_str());
- #endif
2.然后看一下helloWorld.lua是怎么写的吧
local winsize=CCDirector:sharedDirector():getWinSize();
local function createHelloLayer()
local layer=CCLayer:create();
local sprite=CCSrpite:create();
sprite:setPosition(ccp(winSise.width,winSize.height));
layer:addChild(sprite);
return layer;
end
local scene=CCScene:create();
scene:addChild(createHelloLayer());
CCDirector:sharedDirector:runWithScene(scene);
老实说过一遍别人的博客然后再这写,好像不是很好,但是真的能收获很多知识,希望看到的人也可以再学到一点,嘿嘿~
1.一般的变量都要用local xx的形式来写
2.lua的类型由你来设定,你规定是什么就是什么
3.lua中都是:和.没有::
4.不存在->
0 0
- 今天的收获,关于hellolua~
- 今天的收获
- 今天的收获
- 今天的一些收获
- 今天的收获-MindManager
- 今天收获的知识。。。。。。
- 今天的编程收获
- 今天的收获哈
- 今天一天的收获
- 今天的小收获!!
- 今天的收获....
- 今天的一些收获
- 今天的收获
- 今天的收获
- 今天的收获
- 今天的收获
- 今天的收获
- 今天的收获
- 思考使人睿智,思考使人前行
- Apache Avro 与 Thrift 比较
- 信息系统项目管理师总结2
- C++中函数指针的使用
- Android context(Application/Activity)与内存泄露
- 今天的收获,关于hellolua~
- 信息系统项目管理师总结3
- 【腾讯开源】Android性能测试工具APT使用指南
- nyoj-529-flip
- R语言之数据挖掘相关包and函数
- 卸载Android模拟器中软件
- myeclipse破解
- Hibernate的回调与拦截
- NYOJ 741 "数学家"ST