function walkToShop(runTime) {
var defer = $.Deferred();
var doorObj = $('.door')
// 门的坐标
var offsetDoor = doorObj.offset();
var doorOffsetLeft = offsetDoor.left;
// 小孩当前的坐标
var offsetBoy = $boy.offset();
var boyOffetLeft = offsetBoy.left;
// 当前需要移动的坐标
instanceX = (doorOffsetLeft + doorObj.width() / 2) - (boyOffetLeft + $boy.width() / 2);
// 开始走路
var walkPlay = stratRun({
transform: 'translateX(' + instanceX + 'px),scale(0.3,0.3)',
opacity: 0.1
}, 2000);
// 走路完毕
walkPlay.done(function() {
$boy.css({
opacity: 0
})
defer.resolve();
})
return defer;
}
因为构建一个新的异步链