cocos2dx Lua 笔记
好久没有写博客了 打算以后每天写一点 为爱好cocos2dx lua的爱好者贡献一点自己的绵薄之力 我使用的开发工具是vs2012 加lua插件这个网上很容易下载到 vs可以对lua进行调试并且有提示, 还有个小工具就是sublime 加上QuiteXdev 小插件开发起来不错 废话不扯了分享一下干货吧 我使用的版本是Quick-Cocos2dx-Community 3.6 Release 1,转世界坐标 node::convertToWorldSpace(node:getPostion()) 2,加载精灵帧缓存
local spriteFrame = cc.SpriteFrameCache:getInstance()
spriteFrame:addSpriteFrames("particle.plist","particle.png")
3,加载布局文件
ccs.GUIReader:getInstance():widgetFromJsonFile(jsonFile)
4,查找布局中的控件
ccui.Helper:seekWidgetByName(widget,name)
5,播放帧动画
local actionMgrEx = ccs.ActionManagerEx:getInstance()
actionMgrEx:playActionByName(MAIN_UI,"EnterAni")
6,播放骨骼动画 c++版
ArmatureDataManager::getInstance()->addArmatureFileInfo("NewAnimation/NewAnimation0.png" "NewAnimation/NewAnimation0.plist","NewAnimation/NewAnimation.ExportJson");
ArmatureDataManager::getInstance()->addArmatureFileInfo("NewAnimation/NewAnimation.ExportJson");
auto armature = Armature::create("NewAnimation");
armature->getAnimation()->play("Animation1");
7,声音播放
local fileUtils = cc.FileUtils:getInstance()
function MyApp:playMusic(musicfile,isLoop)
if fileUtils:isFileExist(fileUtils:fullPathForFilename(musicfile)) then
audio.playMusic(musicfile,isLoop)
if CONFIG_USER_DATA.MUSIC == 0 then
audio.pauseMusic()
end
end
end
function MyApp:playSound(soundfile)
if fileUtils:isFileExist(fileUtils:fullPathForFilename(soundfile)) then
if CONFIG_USER_DATA.SOUND == 1 then
return audio.playSound(soundfile)
end
end
end
<?xml version="1.0"?>
cocos2dx lua 爱好群489981799
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |