[LayaAir 2.0]spine骨骼动画如何获取某个骨骼的坐标

如题
已邀请:
请问是要做什么东西呢

fligen

赞同来自:

1.设置被需求坐标的骨骼的boneName(美术同学制作骨骼动画时设置好),例如子弹的boneName为xxx;
2.修改引擎Skeleton类,新增以下自封装接口(boneName填xxx),即可获取到某动作某bone名对应的所有帧的骨骼坐标列表:
 
/**
* 根据动作名和插槽骨骼名,来获取该骨骼在该动作播放时,每一帧该骨骼坐标位置,返回所有帧数骨骼坐标位置组成的列表
* @param nameOrIndex
* @param boneName
* @return 骨骼坐标列表
*/
public function getBoneCoords(nameOrIndex:*, boneName:String):Array
{
var arrCoords:Array = ;
 
var aniClipIndex:int = getAniClipIndex(nameOrIndex);
var curOriginalData:Float32Array = new Float32Array(_templet.getTotalkeyframesLength(aniClipIndex));
 
var interval:Number = 1000.0 / _player.cacheFrameRate;
var playTime:Number = _templet.getAniDuration(aniClipIndex);
var lenJ:int = playTime / interval;
for (var j:int = 0; j < lenJ; j++)
{
var curTime:Number = j * _player.cacheFrameRateInterval;
_templet.getOriginalData(aniClipIndex, curOriginalData, _player._fullFrames[aniClipIndex], j, curTime);
 
var tStartIndex:int = 0;
var tParentTransform:Transform;
var tSrcBone:Bone;
var boneCount:int = _templet.srcBoneMatrixArr.length;
var tSectionArr:Array = _aniSectionDic[aniClipIndex];
var i:int = 0, n:int = 0;
for (i = 0, n = tSectionArr[0]; i < boneCount; i++)
{
tSrcBone = _boneList;
tParentTransform = _templet.srcBoneMatrixArr[i];
tStartIndex++;
tStartIndex++;
tStartIndex++;
tStartIndex++;
var boneX:Number = tParentTransform.x + curOriginalData[tStartIndex++];
var boneY:Number = tParentTransform.y + curOriginalData[tStartIndex++];
if (tSrcBone.name == boneName)
{
arrCoords.push(boneX);
arrCoords.push(boneY);
break;
}
if (_templet.tMatrixDataLen === 8)
{
tStartIndex++;
tStartIndex++;
}
}
}
 
return arrCoords;
}
[/i]

要回复问题请先

商务合作
商务合作