-- 定义动画状态机 AnimEntityStatus = { [1] = { stateName = "death", stateValues = { [1] = {animation = "death" , loop = false , staticWhenEnd = true}; }; }; [2] = { stateName = "skill", stateValues = { [1] = {animation = "spell" , loop = false}; [2] = {animation = "spell2" , loop = false}; }; }; [3] = { stateName = "attack", stateValues = { [1] = {animation = "attack" , loop = false}; }; }; [4] = { stateName = "move", stateValues = { [0] = {animation = "stand" , loop = true , randomPosition = true}; [1] = {animation = "walk" , loop = true , randomPosition = true}; [2] = {animation = "walk2" , loop = true , randomPosition = true}; }; } } cc.AnimEntityUtils:getInstance():setAnimGroupSet(AnimEntityStatus) -- 创建英雄动画实例 function createHeroEntity(skeleton) if type(skeleton.createAnimEntity) == "function" then skeleton:createAnimEntity() local animEntity = skeleton:getAnimEntity(); -- 默认播放站立动画 animEntity:updateState("move", 0); return animEntity end return nil end