- UID
- 260618
- 在线时间
- 小时
- 积分
- 278
- 帖子
- 离线
- 18692 天
- 注册时间
- 2006-5-8
|
做了一个跟随鼠标移动的动画,可是总是计算不出移动到上端和下段的公式,向大家求助了
本来应该是:
mc._x += (targetX-mc._x)/speed
但我按这个公式算出来却不对,调了好久才弄出了个这样的东西:
pic.setMask(mask);
pic.onRelease = function() {
this._yscale = 200;
mouse_stard._x = _xmouse
mouse_stard._y = _ymouse
this.onEnterFrame = function() {
trace("我的位置是 = "+this._y);
if (_xmouse>36 && _xmouse<988 && _ymouse>61 && _ymouse<707) {
Mouse.hide();
mouse_up._visible = true;
startDrag("mouse_up", true);
if (_ymouse<mouse_stard._y) {
mouse_up.gotoAndStop("up");
if (this._y<61) {
this._y += (61-this._y-_ymouse)/5;
}
} else if (_ymouse>(mouse_stard._y+34)) {
mouse_up.gotoAndStop("down");
if (this._y>-707) {
this._y += (-_ymouse-this._y)/5;
}
} else {
mouse_up.gotoAndStop("middle");
}
}else{
Mouse.show();
mouse_up._visible = false;
this._y = this._y
}
};
};
鼠标移动公式.rar
(144.25 KB, 下载次数: 187)
|
|