当前位置: 首页 > news >正文

Spine的BoundingBoxAttachment碰撞检测

引擎版本 —— cocos creator 2.3.4

游戏代码:

 //优先初始化的时候,获取到cc.PhysicsPolygonColliderthis._poly = this.dragonFooAni.node.getComponent(cc.PhysicsPolygonCollider);//下面的修改顶点位置的方法可以在update里面去执行//获取骨骼动画上的挂件         str1:动画的父节点 str2:动画let attachment = this.skAni.getAttachment('pengzhuang2', 'pengzhuang3');//获取骨骼let slot = this.skAni.findSlot('pengzhuang2');//获取顶点的位置let arr = [];attachment.computeWorldVertices(slot, 0, attachment.worldVerticesLength, arr, 0, 2)//console.log("多边形挂件:", attachment, "多边形顶点:", arr.toString());for (let i = 0; i < 4; i++) {this._poly.points[i].x = arr[i * 2];this._poly.points[i].y = arr[i * 2 + 1];
}
this._poly.apply();

在原生环境下没有computeWorldVertices接口,我们需要复写引擎中的computeWorldVertices方法

_computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {count = offset + (count >> 1) * stride;let deformArray = slot.deform;let vertices;if (deformArray.length > 0)vertices = deformArray;if (!vertices)return;let bone = slot.bone;let x = bone.worldX;let y = bone.worldY;let a = bone.a, b = bone.b, c = bone.c, d = bone.d;for (let v_1 = start, w = offset; w < count; v_1 += 2, w += stride) {let vx = vertices[v_1], vy = vertices[v_1 + 1];worldVertices[w] = vx * a + vy * b + x;worldVertices[w + 1] = vx * c + vy * d + y;}return;};

http://www.lryc.cn/news/240926.html

相关文章:

  • Proteus下仿真AT89C51报“串行口通信失败,请检查电平适配是否正确。”解决办法
  • 微信小程序制作
  • 快速在WIN11中本地部署chatGLM3
  • 土地利用数据技术服务
  • qml动画过渡Transition
  • Django(九、cookie与session)
  • web前端之若依框架图标对照表、node获取文件夹中的文件名,并通过数组返回文件名、在html文件中引入.svg文件、require、icon
  • 使用 goland 开发 golang 项目环境配置
  • Linux宝塔面板搭建Discuz论坛, 并内网穿透实现公网访问
  • [git] 忽略已经提交的文件或文件夹
  • 大模型增量预训练参数说明
  • 成为AI产品经理——模型评估概述
  • 内存屏障与JVM指令
  • 深入理解JVM 类加载机制
  • SpringCloud微服务 【实用篇】| Eureka注册中心、Ribbon负载均衡
  • SpringSecurity+JWT权限认证
  • Tomcat实现WebSocket即时通讯 Java实现WebSocket的两种方式
  • 安全框架springSecurity+Jwt+Vue-2(后端开发)
  • 6.1.webrc媒体协商
  • Android WebView中打开外部超链接无反应
  • JMeter集结点的使用场景以及如何使用?
  • 2023最新面试题
  • shell 脚本的函数和数组
  • 【RocketMq系列-02】RocketMq的架构解析和高性能设计
  • 【数据结构/C++】线性表_单链表的基本操作
  • flink1.13.6版本的应用程序(maven版)
  • 深度学习之四(循环神经网络Recurrent Neural Networks,RNNs)
  • 【论文精读】HuggingGPT: Solving AI Tasks with ChatGPT and its Friends in Hugging Face
  • 安装gitlab
  • Nginx模块开发之http handler实现流量统计(1)