如何在补间结束后更改最后两行的代码?这时,我得到了最后两个日志,声音播放了,同时tween开始了。在播放声音的同时,青少年结束了,我得到了最后一个日志("tween“)。
var tween = new Kinetic.Tween({
node: mynode,
duration: 100,
x: 100,
y: 200,
scaleX: 80,
scaleY: 80,
onFinish: function() {
console.log("Tween finished");
}
});
tween.play();
//The next lines should be executed after the onFinish-event
console.log("This should be the first log");
console.log("Executed before 'Tween finished'");
.. do something e.g. play a sound发布于 2015-08-31 22:58:14
只需将其放入另一个函数中并从onFinish中调用它:
var func2 = function() {
console.log("This should be the first log");
console.log("Executed before 'Tween finished'");
// .. do something e.g. play a sound
}
var tween = new Kinetic.Tween({
node: mynode,
duration: 100,
x: 100,
y: 200,
scaleX: 80,
scaleY: 80,
onFinish: function() {
console.log("Tween finished");
func2();
}
});
tween.play();https://stackoverflow.com/questions/32299736
复制相似问题