update method
精灵更新
Implementation
@override
void update(double dt) {
/// 控制动画帧切换
if (this.frames[this.currentAnimation] != null && this.frames[this.currentAnimation]!.length > 0) {
List<DFImageSprite> sprites = this.frames[this.currentAnimation]!;
/// 控制动画帧按照stepTime进行更新
if (DateTime.now().millisecondsSinceEpoch - this.frameClock > this.stepTime) {
this.frameClock = DateTime.now().millisecondsSinceEpoch;
if (sprites.length > this.currentIndex + 1) {
this.currentIndex = this.currentIndex + 1;
} else {
/// 如果循环就从0再次开始
if (this.loop) {
this.currentIndex = 0;
} else {
/// 动画播放到完成
if (onComplete != null) {
onComplete!(this);
}
}
}
}
}
super.update(dt);
}