当前位置:网站首页>cocoscreator播放Spine动画
cocoscreator播放Spine动画
2022-06-26 06:38:00 【RemoteDev】
1.创建2D空工程

2.工程打开默认场景,默认场景中已添加画布

3.在画布中添加空节点

4.命名节点为NodeSke
5.添加骨骼动画(Spine)组件到空节点上

添加成功后,点击NodeSke节点,可看到属性检查器上已添加了sp.Skeleton节点
6.将Spine动画文件夹拖到assets目录

展开Spine动画目录girl可看到相关动画文件

7.将Spine动画json文件拖到Skeleton Data中
选择指定皮肤


选择皮肤后,场景中空节点出现动画画布

8.调整动画位置
动画位置调整OK
保存刚才制作的场景为main

9.选中摄影机,并切换Layer为UI_2D,可看到摄影机已将场景中画布渲染出来了

10.点击预览在浏览器中查看效果

11.选中空节点NodeSke,然后在右边的属性检查器中选择要默认播放的动画

现在,浏览器中可看到Spine动画已自动播放了

12.通过脚本控制动画播放,停止,及切换动画皮肤
a.添加脚本文件

b.为NodeSke节点添加自定义脚本
c.双击脚本打开VSCODE并在girl.ts中添加播放动画与停止动画方法

d.节点与变量关联
将节点拖入变量
e.添加动画控制按钮

f.为按钮添加变量关联

g.为按钮添加点击事关联


编码实现Spine动画播放,停止,换肤功能
//播放动画
playAnimation(){
this.SkeObj.setAnimation(0,"dance",true);
}
//停止动画
stopAnimation(){
let SpEnt:sp.spine.TrackEntry = this.SkeObj.setAnimation(0,"dance",true);
SpEnt.animationStart = SpEnt.animationEnd;
}
//换肤
changeSkin() {
const skins =['girl', 'boy', 'girl-blue-cape', 'girl-spring-dress'].map(x=> `full-skins/${x}`);
this.skinId = (this.skinId + 1) % skins.length;
this.SkeObj!.setSkin(skins[this.skinId]);
}
演示:
边栏推荐
- Decompile Android applications, interview Android
- Laravel implements groupby to query the number of packets
- Research Report on market supply and demand and strategy of China's microneedle device industry
- [micro service series] protocol buffer dynamic analysis
- Top down transformation method
- Understanding of nil in go language
- Screen sharing recommendations
- LabVIEW Arduino TCP/IP远程智能家居系统(项目篇—5)
- Open source demo| you draw and I guess -- make your life more interesting
- Gof23 - builder mode
猜你喜欢
Experience the new features of Milvus 2.0 together

Installation and login of MySQL database

vs code 使用 prettier 格式化 js 的时候, 函数定义的名称和括号之间有一个空格, 而 eslit 又不允许这个空格.
![[digital signal processing] basic sequence (basic sequence lists | unit pulse sequence | unit pulse function | discrete unit pulse function | difference between unit pulse function and discrete unit p](/img/bf/16ea6e1283adda928f62c6f416b254.jpg)
[digital signal processing] basic sequence (basic sequence lists | unit pulse sequence | unit pulse function | discrete unit pulse function | difference between unit pulse function and discrete unit p

TCP connection and disconnection, detailed explanation of state transition diagram

Vulnerability discovery - API interface service vulnerability probe type utilization and repair

Web technology sharing | webrtc recording video stream

Load balancer does not have available server for client: userservice problem solving

C nuget offline cache package installation

Live broadcast Preview - fire safety instructor training "cloud class" is about to start!
随机推荐
DS18B20详解
Dpdk - tcp/udp protocol stack server implementation (I)
How can an enterprise successfully complete cloud migration?
Ppt template crawler case
Custom reference formats used by Zotero
SecureCRT运行SparkShell 删除键出现乱码的解法
The sysdig 2022 cloud native security and usage report found that more than 75% of the running containers have serious vulnerabilities
温度报警器
Number of connections server database message: error number 2003can't connect to MySQL server on 'server address' (10061)
DS18B20 details
Library management system
SHOW语句用法补充
【golang】time相关
Spark3.3.0源码编译补充篇-抓狂的证书问题
~94 zoom
STM 32 uses cube to generate Tim to trigger ADC and transmit through DMA
Installing rainbow in various kubernetes with Helm
MYSQL触发器要如何设置,简单教程新手一看就会
Understanding of nil in go language
MYSQL索引不生效的原因