armature

来源:互联网 发布:淘宝永久封店保证金 编辑:程序博客网 时间:2024/06/05 17:31


-- 获取Armature配置文件路径

function GetArmatureFilePath(name)local armatureResourceRelativePaths = {"res/image/sprite/","res/image/effect/",}for i=1,#armatureResourceRelativePaths dolocal relativePath = armatureResourceRelativePaths[i]..name.."/"local relativeFileName = relativePath..name..".ExportJson"local isExist = cc.FileUtils:getInstance():isFileExist(relativeFileName)if isExist thenreturn relativeFileNameendendreturn nilend function ArmatureResourceManager:loadArmature(name)if name == nil thenreturn falseend local armatureDataManager = ccs.ArmatureDataManager:getInstance()local animationData = armatureDataManager:getAnimationData(name)if nil == animationData thenlocal resourcePath = GetArmatureFilePath(name)if resourcePath thenarmatureDataManager:addArmatureFileInfo(resourcePath)elsecclog(string.format("Failure to found Armature '%s' in ArmatureResourceList", name))return falseendendreturn trueend



 

-- 特效-armature

local effectName = 'ef_weilan'local ret = ArmatureResourceManager.getInstance():loadArmature(effectName)if ret then          self.mEffectSprite = ccs.Armature:create(effectName)          local effectPosition = cc.p(500,500)          self.mEffectSprite:setPosition(effectPosition)          self:addChild(self.mEffectSprite)           self.mEffectSprite:getAnimation():playWithIndex(0)          -- 参数 armature,完成程度,动作名称(idle)  ,动作完成后的回调          local function animationEvent(armatureBack, movementType,movementID)              local id = movementID              if movementType == ccs.MovementEventType.complete then              end          end       self.mEffectSprite:getAnimation():setMovementEventCallFunc(animationEvent) endfarmature = ccs.Armature:create("n02")farmature :getAnimation():play("idle01")-- 初始化为第0帧bgComponentluobo:getAnimation():gotoAndPause(0)


 

0 0
原创粉丝点击