我在 Flash 中创建了一个地图,我希望有一个类似这样的平滑运动:http: //www.conceptm.nl/
我已经开始了,但我无法将其带入下一阶段。
我的代码当前在释放鼠标后会抛出影片剪辑,但在鼠标按钮按下时没有缓动。
关于如何实现这一目标的任何提示?
这是我当前的代码:
// Vars
var previousPostionX:Number;
var previousPostionY:Number;
var throwSpeedX:Number;
var throwSpeedY:Number;
var isItDown:Boolean;
// Event Listeners
addEventListener(MouseEvent.MOUSE_DOWN, clicked);
addEventListener(MouseEvent.MOUSE_UP, released);
// Event Handlers
function clicked(theEvent:Event) {
isItDown =true;
addEventListener(Event.ENTER_FRAME, updateView);
}
function released(theEvent:Event) {
isItDown =false;
}
function updateView(theEvent:Event) {
if (isItDown==true){
throwSpeedX = mouseX - previousPostionX;
throwSpeedY = mouseY - previousPostionY;
mcTestMovieClip.x = mouseX;
mcTestMovieClip.y = mouseY;
}
else{
mcTestMovieClip.x += throwSpeedX;
mcTestMovieClip.y += throwSpeedY;
throwSpeedX *=0.9;
throwSpeedY *=0.9;
}
previousPostionX= mcTestMovieClip.x;
previousPostionY= mcTestMovieClip.y;
}