mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
@@ -80,7 +80,7 @@ p.setStateTime = function (state, time) {
|
||||
|
||||
p.onStop = function () {
|
||||
var anims = this.playingAnims;
|
||||
for (var i = 0, l = anims.length; i < l; i++) {
|
||||
for (var i = anims.length - 1; i >= 0; i--) {
|
||||
anims[i].stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,12 @@ state.onPlay = function () {
|
||||
this.setTime(0);
|
||||
};
|
||||
|
||||
state.onStop = function () {
|
||||
if (this.animator) {
|
||||
this.animator.removeAnimation(this);
|
||||
}
|
||||
};
|
||||
|
||||
state.setTime = function (time) {
|
||||
this.time = time || 0;
|
||||
|
||||
|
||||
@@ -21,26 +21,32 @@ var animProto = Animator.prototype;
|
||||
animProto.update = function (dt) {
|
||||
this._updating = true;
|
||||
|
||||
var anims = this.playingAnims;
|
||||
var i, l;
|
||||
var anims = this.playingAnims;
|
||||
var stoppedCount = 0;
|
||||
|
||||
for (i = 0, l = anims.length; i < l; i++) {
|
||||
var anim = anims[i];
|
||||
if (anim._isPlaying && !anim._isPaused) {
|
||||
anim.update(dt);
|
||||
|
||||
if (!anim._isPlaying) {
|
||||
stoppedCount ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._updating = false;
|
||||
|
||||
if (anims.length === 0 || stoppedCount >= anims.length ) {
|
||||
this.stop();
|
||||
}
|
||||
|
||||
var removeList = this._removeList;
|
||||
for (i = 0, l = removeList.length; i < l; i++) {
|
||||
this.removeAnimation( removeList[i] );
|
||||
}
|
||||
removeList.length = 0;
|
||||
|
||||
if (anims.length === 0) {
|
||||
this.stop();
|
||||
}
|
||||
};
|
||||
|
||||
animProto.onPlay = function () {
|
||||
@@ -48,7 +54,6 @@ animProto.onPlay = function () {
|
||||
};
|
||||
|
||||
animProto.onStop = function () {
|
||||
this.playingAnims.length = 0;
|
||||
cc.director.getAnimationManager().removeAnimator(this);
|
||||
};
|
||||
|
||||
|
||||
@@ -347,15 +347,6 @@ JS.mixin(AnimationNode.prototype, {
|
||||
}
|
||||
|
||||
return info.stopped;
|
||||
},
|
||||
|
||||
//onPlay: function () {
|
||||
//},
|
||||
|
||||
onStop: function () {
|
||||
if (this.animator) {
|
||||
this.animator.removeAnimation(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1125,5 +1125,16 @@ test('stop Animation', function () {
|
||||
|
||||
strictEqual(animationManager.animators.length, 0, 'playing animators should be 0');
|
||||
strictEqual(animation._animator.playingAnims.length, 0, 'playing anims should be 0');
|
||||
|
||||
animation.play('test');
|
||||
animationManager.update(0.5);
|
||||
|
||||
strictEqual(animationManager.animators.length, 1, 'playing animators should be 1');
|
||||
strictEqual(animation._animator.playingAnims.length, 1, 'playing anims should be 1');
|
||||
|
||||
animation.stop();
|
||||
|
||||
strictEqual(animationManager.animators.length, 0, 'playing animators should be 0');
|
||||
strictEqual(animation._animator.playingAnims.length, 0, 'playing anims should be 0');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user