我必须制作横幅广告 (swf)。所以我在中间有一个圆形对象,当你在右侧移动鼠标时我需要从左向右旋转,当你在左侧移动鼠标时我需要从右向左旋转。有任何想法吗?谢谢!
问问题
225 次
1 回答
1
有很多方法可以做到这一点,但先试试这个,看看它是否是你要找的:
private var rotationStep = .25;
private var newX:int;
private var oldX:int;
public Main():void {
// Initialization of your stuff
// When ready add this to track the mouse
this.stage.addEventListener(MouseEvent.MOUSE_MOVE,followMouse);
}
private function followMouse(e:MouseEvent):void {
if(this.newX > this.oldX) {
this.rotate(1);
} else {
this.rotate(-1);
}
this.oldX = this.newX;
}
private function rotate(dir:int):void {
// rotate ball based on direction
this.ball.rotoationZ += this.rotationStep*dir;
}
记住旋转是以弧度为单位的,而不是度数
于 2012-11-28T18:34:25.827 回答