当前位置:网站首页>Cocoscreator operates spine for animation fusion
Cocoscreator operates spine for animation fusion
2022-07-07 14:42:00 【Snail games】
Animation fusion
When there are multiple animations on a bone , We can use sp.setAnimation() Play animation
however , Use it directly sp.setAnimation() When playing , There will be a problem of rigid animation switching , This kind of trace affects the experience of the game , So based on the spine stay Cocos Medium API We can fuse the two animations
What is animation fusion
As can be seen in the picture Idle and Walking There is overlap between , The red line is the switching action time , The action switching time is between the red and green lines , The animation between them is Idle And Walking Mixing , There will be a smooth transition between these two animations

Fusion code implementation ( Jane , No weight )
First use an animation playback pipeline to play an animation
this.spine_node.setAnimation(0, 'Idle', true);
Here I get Idle The animation time of
getAnimationTimeByName() I inherited it sp.Skeleton Custom methods , Mount in the project spine This inheritance class will be used everywhere
const time = this.spine_node.getAnimationTimeByName('Idle');
/**
* Get animation time
* @param name Animation name
* @returns Return to animation duration s
*/
public getAnimationTimeByName(name: string) {
const state = this.getState();
if (state == undefined) throw `[ERROR SPINE ANIMATION] Unable to get animation status >`;
const { animations } = state.data.skeletonData;
let result = 0;
for (const key in animations) {
if (Object.prototype.hasOwnProperty.call(animations, key)) {
const element = animations[key];
if (element.name == name) {
result = element.duration;
}
}
}
return result;
}
Still play Idle Animated pipeline , Add Walking Animation , And delay two Idle Play after animation time ( Time can be customized , His unit is seconds )
this.spine_node.addAnimation(0, 'Walking', true, time * 2);
The last thing to do is mix , This step is to generate the part between the red and green lines
time It refers to the time between the red and green lines , In this case, it means , stay Idle Mix after the first period of playback Walking Animation , Produce a smooth transition
this.spine_node.setMix('Idle', 'Walking', time);
Complete code
this.spine_node.clearTracks();
this.spine_node.setAnimation(0, 'Idle', true);
const time = this.spine_node.getAnimationTimeByName('Idle');
this.spine_node.addAnimation(0, 'Walking', true, time * 2);
this.spine_node.setMix('Idle', 'Walking', time);
边栏推荐
- Oracle Linux 9.0 正式发布
- Shengteng experience officer Episode 5 notes I
- Démontage de la fonction du système multi - Merchant Mall 01 - architecture du produit
- Pinduoduo lost the lawsuit, and the case of bargain price difference of 0.9% was sentenced; Wechat internal test, the same mobile phone number can register two account functions; 2022 fields Awards an
- MicTR01 Tester 振弦采集模块开发套件使用说明
- Similarities and differences between switches and routers
- Substance painter notes: settings for multi display and multi-resolution displays
- AWS学习笔记(三)
- 拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条...
- Leetcode——236. 二叉树的最近公共祖先
猜你喜欢

GAN发明者Ian Goodfellow正式加入DeepMind,任Research Scientist

Use case diagram

Ian Goodfellow, the inventor of Gan, officially joined deepmind as research scientist

潘多拉 IOT 开发板学习(HAL 库)—— 实验12 RTC实时时钟实验(学习笔记)

Instructions for mictr01 tester vibrating string acquisition module development kit

MRS离线数据分析:通过Flink作业处理OBS数据

AWS学习笔记(三)

Pinduoduo lost the lawsuit, and the case of bargain price difference of 0.9% was sentenced; Wechat internal test, the same mobile phone number can register two account functions; 2022 fields Awards an

⼀个对象从加载到JVM,再到被GC清除,都经历了什么过程?

The longest ascending subsequence model acwing 1014 Mountaineering
随机推荐
解析PHP跳出循环的方法以及continue、break、exit的区别介绍
NLLB-200:Meta开源新模型,可互译200种语言
Summary on adding content of background dynamic template builder usage
electron remote 报错
Webrtc audio anti weak network technology (Part 1)
Data Lake (IX): Iceberg features and data types
Wechat applet - Advanced chapter component packaging - Implementation of icon component (I)
在软件工程领域,搞科研的这十年!
Leetcode——236. 二叉树的最近公共祖先
什么是云原生?这回终于能搞明白了!
[Yugong series] go teaching course 005 variables in July 2022
Pinduoduo lost the lawsuit, and the case of bargain price difference of 0.9% was sentenced; Wechat internal test, the same mobile phone number can register two account functions; 2022 fields Awards an
A laravel background management expansion package you can't miss - Voyager
寺岗电子称修改IP简易步骤
Cvpr2022 | backdoor attack based on frequency injection in medical image analysis
2022年13个UX/UI/UE最佳创意灵感网站
GAN发明者Ian Goodfellow正式加入DeepMind,任Research Scientist
ES日志报错赏析-maximum shards open
Data connection mode in low code platform (Part 2)
Bashrc and profile