egret spine 对接实现

SkeletonAnimation 继承自 egret.DisplayObjectContainer

里面监听了 egret.Event.ENTER_FRAME事件

他里面有一个 SkeletonRenderer

这个是渲染用的

他会靠这个代码驱动

this.renderer.update(now - this.lastTime);

typescript 复制代码
public update(dt: number) {
   this.state.update(dt);
    this.state.apply(this.skeleton);
    this.skeleton.updateWorldTransform();
    const drawOrder = this.skeleton.drawOrder;
    for (let i = 0; i < drawOrder.length; i++) {
        const index = drawOrder[i].data.index;
        const renderer = this.slotRenderers[index];
        if (renderer.zIndex !== i) {
            renderer.zIndex = i;
        }
        renderer.renderSlot(this);
    }
    this.clipper.clipEnd();
}

SkeletonRenderer

RegionAttachment里的computeWorldVertices方法

这个是计算在世界坐标系里的位置

他需要这几个参数

bash 复制代码
bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number

看描述

bash 复制代码
/** Transforms the attachment's four vertices to world coordinates.
*
* See [World transforms](http://esotericsoftware.com/spine-runtime-skeletons#World-transforms) in the Spine
* Runtimes Guide.
* @param worldVertices The output world vertices. Must have a length >= `offset` + 8.
* @param offset The `worldVertices` index to begin writing values.
* @param stride The number of `worldVertices` entries between the value pairs written. */

worldVertices 是输出用的

offset 代表数组写入从几开始

stride 代表写入一组数据后 跳过几个索引

一般来说 到这里的bone 已经处理过数据了 他里面的worldX 和 worldY可以直接使用了

相关推荐
赤生云电竞3 天前
云游戏边缘节点部署:机房选址与网络拓扑优化实践 —— 从80ms时延预算看节点落位与Spine-Leaf组网
服务器·游戏·spine
LightBreeze200210 天前
深入理解 Leaf-Spine:从网络拓扑到 AI 数据中心 Fabric
人工智能·fabric·spine·叶脊网络
avi911118 天前
【AI教人】UnityEditor扩展Spine动画,Spine骨骼,预览Preview一切
spine·骨骼动画·1024程序员节·editor扩展·spine动画·spine骨骼
星融元asterfusion21 天前
工业网络升级实战:100G 双轨 Leaf-Spine 架构破解高并发出货网络瓶颈
网络·架构·spine
年少无知且疯狂1 个月前
【Unity】Shader spine动画冻结效果
unity·spine
那年窗外下的雪.3 个月前
AIDC 学习日志|第 14 天|MAC Flapping 与 EVPN 多归属分层排障
网络·git·学习·macos·github·spine
那年窗外下的雪.3 个月前
VXLAN EVPN 分层排障:从 VTEP 可达、ARP/MAC 到 MAC Mobility
服务器·前端·网络·数据库·spine
molihuan4 个月前
最新 spine 4.3 flutter 适配鸿蒙
flutter·动画·harmonyos·鸿蒙·spine
YigAin4 个月前
Unity Spine 资源出现白边的解决办法
unity·游戏引擎·spine
Huanzhi_Lin5 个月前
spine相关概念
spine·slots·ik·animations·bones·skins·skeleton