[LayaAir 2.0]Spine动画最后一帧无法正常显示
使用LayaAir 2.4.0正式版播放动画,选择只播放一次(Skeleton.play(0,false)),发现在播放完后未显示最后一帧画面。经调试后发现在Skeleton::_update方法中的以下语句:
对于Spine动画播放的源码我没有全部看一遍故不能找到故障根源,据我多次试验发现,有时候能显示正常而大多数时候都是显示为倒数第二帧的画面。对比Laya 2.4.0及2.0.2版本的laya.ani.js后发现老版本在代码中多了一段,将这段代码加到新版本的代码中就会变成这样:
附件中是我所使用的spine动画文件,使用方法为直接拖到LayaAirIDE的UI编辑器场景中,之后通过脚本访问其var值进行播放。
var tGraphics;决定动画外观的语句为this.graphics = tGraphics这句,当动画停在最后一帧时其使用的graphics值与倒数第二帧graphics使用的x/y/width/height一致,故猜测最后一帧使用了和倒数第二帧一样的外观导致动画停止后外观看起来还是倒数第二帧的外观。
if (this._aniMode == 0) {
tGraphics = this._templet.getGrahicsDataWithCache(this._aniClipIndex, this._clipIndex) || this._createGraphics();
if (tGraphics && this.graphics != tGraphics) {
this.graphics = tGraphics;
}
}
对于Spine动画播放的源码我没有全部看一遍故不能找到故障根源,据我多次试验发现,有时候能显示正常而大多数时候都是显示为倒数第二帧的画面。对比Laya 2.4.0及2.0.2版本的laya.ani.js后发现老版本在代码中多了一段,将这段代码加到新版本的代码中就会变成这样:
var tGraphics;此时问题解决。不过这只是治标不治本的方法,不知道官方是否能凭此得到什么线索以便日后可以彻底修复此问题。
if (this._aniMode == 0) {
// tGraphics = this._templet.getGrahicsDataWithCache(this._aniClipIndex, this._clipIndex) || this._createGraphics();
tGraphics = this._templet.getGrahicsDataWithCache(this._aniClipIndex, this._clipIndex);
if(!tGraphics){
var i=0,minIndex=this._clipIndex;
while ((!this._templet.getGrahicsDataWithCache(this._aniClipIndex,minIndex-1))&& (minIndex > 0)){
minIndex--;
}
if (minIndex < this._clipIndex){
for (i=minIndex;i < this._clipIndex;i++){
this._createGraphics(i);
}
}
tGraphics = this._templet.getGrahicsDataWithCache(this._aniClipIndex, this._clipIndex);
}
if (tGraphics && this.graphics != tGraphics) {
this.graphics = tGraphics;
}
}
附件中是我所使用的spine动画文件,使用方法为直接拖到LayaAirIDE的UI编辑器场景中,之后通过脚本访问其var值进行播放。
要回复问题请先登录
1 个回复
Aar0n
赞同来自: