使用Lua创建cocostudio导出的骨骼动画失败

创建了一个空的lua工程,使用cocostudio导出动画,尝试创建显示,但是在create的时候失败了,求点解原因。
代码如下,增加打印发现create那里出错了,但没有说明原因
require “Cocos2d”
require “Cocos2dConstants”

local GameScene = class(“GameScene”,function()
return cc.Scene:create()
end)

function GameScene.create()
local scene = GameScene.new()
–scene:addChild(scene:createLayerFarm())
–scene:addChild(scene:createLayerMenu())
scene:addChild(scene:createAni())
return scene
end

function GameScene:createAni()
local layerTest = cc.Layer:create()
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo(“Hero.exportJson”)
local armature = ccs.Armature:create(“Hero”)
armature:setPosition(cc.p(VisibleRect:center()))
armature:getAnimation():playWithIndex(0)
layerTest:addChild(armature)
return layerTest
end

ccs.ArmatureDataManager:getInstance():addArmatureFileInfo(“res/aaa.ExportJson”)
local armature = ccs.Armature:create(“aaa”)
armature:setPosition(280,80)
armature:getAnimation():playWithIndex(“2”)
return armature

以上是一个场景方法示例,看你的没有什么问题, layerTest:addChild(armature) 这一句代码如果你用2.x版本可能会有冲突,继续log定位到出错的那句话吧。

cocos2dx版本是3.2,要不log到create函数里面?程序直接崩溃了。这里有没有文件加载的问题,是不是需要的文件还没加载完成导致create失败?

这个情况 我也遇到过,可能是你导出动画的时候,导出了多次,有些plist 文件修改了名字,但是在ExportJson 的配置中,就的plist 还存在,所以会导致报错。
解决:1、手动修改ExportJson(删除旧的相关配置)。2、整个动画重做