在 Actionscript 中一个接一个地使用补间动画?
Motions with tweens one after another in Actionscript?
我在动作和补间方面遇到了一些问题:
我想将精灵移动到右下角 (800,600),然后移动到左上角 (0,0)。但是我的孩子们没有在等对方。
motion.toBotCorner(currentSprite);
motion.toTopCorner(currentSprite);
这是我的议案class:
public function toBotCorner(currSpr:Sprite):void {
TweenLite.to(currSpr, 3, {x:800, y:600});
}
public function toTopCorner(currSpr:Sprite):void {
TweenLite.to(currSpr, 3, {x:0, y:0});
}
如何使第一个进程然后第二个进程?谢谢!
您应该在您的第一个动画中使用 TweenLite 提供的 'onComplete'。它需要一个方法名,并使用'onCompleteParams'将参数发送给方法调用。
所以,您的代码现在看起来像这样:
public function toBotCorner(currSpr:Sprite):void {
TweenLite.to(currSpr, 3, {x:800, y:600, onComplete:toTopCorner, onCompleteParams:[currSpr]});
}
public function toTopCorner(currSpr:Sprite):void {
TweenLite.to(currSpr, 3, {x:0, y:0});
}
请注意,onCompleteParams: 是一个数组,因为方法可以传递多个参数。
文档是这样说的:
onComplete : Function - 补间完成时应调用的函数
onCompleteParams : Array - 传递 onComplete 函数的参数数组。
希望这对您有所帮助。如果对您有用,请接受此答案,这将关闭问题。谢谢!
我在动作和补间方面遇到了一些问题: 我想将精灵移动到右下角 (800,600),然后移动到左上角 (0,0)。但是我的孩子们没有在等对方。
motion.toBotCorner(currentSprite);
motion.toTopCorner(currentSprite);
这是我的议案class:
public function toBotCorner(currSpr:Sprite):void {
TweenLite.to(currSpr, 3, {x:800, y:600});
}
public function toTopCorner(currSpr:Sprite):void {
TweenLite.to(currSpr, 3, {x:0, y:0});
}
如何使第一个进程然后第二个进程?谢谢!
您应该在您的第一个动画中使用 TweenLite 提供的 'onComplete'。它需要一个方法名,并使用'onCompleteParams'将参数发送给方法调用。
所以,您的代码现在看起来像这样:
public function toBotCorner(currSpr:Sprite):void {
TweenLite.to(currSpr, 3, {x:800, y:600, onComplete:toTopCorner, onCompleteParams:[currSpr]});
}
public function toTopCorner(currSpr:Sprite):void {
TweenLite.to(currSpr, 3, {x:0, y:0});
}
请注意,onCompleteParams: 是一个数组,因为方法可以传递多个参数。
文档是这样说的:
onComplete : Function - 补间完成时应调用的函数
onCompleteParams : Array - 传递 onComplete 函数的参数数组。
希望这对您有所帮助。如果对您有用,请接受此答案,这将关闭问题。谢谢!