最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
用鼠标控制图片移动的效果动画
时间:2022-07-02 17:10:41 编辑:袖梨 来源:一聚教程网
制作方法非常简单:
首先准备一幅大的图片(图片尽量足够大),导入到Flash库中,然后建立一个影片剪辑map,把图片放到这里来,调整到合适位置。
然后再建立一个影片剪辑,制作一个箭头。
回到主场景中在第一帧添加如下代码:
Mouse.hide();
_root.attachMovie("map", "map", 1);
_root.attachMovie("the_arrow", "the_arrow", 2, {_x:250, _y:175});
the_arrow.onEnterFrame = function() {
this._x += (_xmouse-this._x)/5;
this._y += (_ymouse-this._y)/5;
dist_x = this._x-250;
dist_y = this._y-175;
angle = Math.atan(dist_y/dist_x)/(Math.PI/180);
if (dist_x<0) {
angle += 180;
}
if (dist_x>=0 and dist_y<0) {
angle += 360;
}
this._rotation = angle;
deltax = -(this._x-250)/90;
deltay = -(this._y-175)/90;
map._x += deltax;
map._y += deltay;
if (map._x>1000) {
map._x = 1000;
}
if (map._x<-500) {
map._x = -500;
}
if (map._y>1000) {
map._x = 1000;
}
if (map._y<-650) {
map._y = -650;
}
};
_root.attachMovie("map", "map", 1);
_root.attachMovie("the_arrow", "the_arrow", 2, {_x:250, _y:175});
the_arrow.onEnterFrame = function() {
this._x += (_xmouse-this._x)/5;
this._y += (_ymouse-this._y)/5;
dist_x = this._x-250;
dist_y = this._y-175;
angle = Math.atan(dist_y/dist_x)/(Math.PI/180);
if (dist_x<0) {
angle += 180;
}
if (dist_x>=0 and dist_y<0) {
angle += 360;
}
this._rotation = angle;
deltax = -(this._x-250)/90;
deltay = -(this._y-175)/90;
map._x += deltax;
map._y += deltay;
if (map._x>1000) {
map._x = 1000;
}
if (map._x<-500) {
map._x = -500;
}
if (map._y>1000) {
map._x = 1000;
}
if (map._y<-650) {
map._y = -650;
}
};
保存测试吧!在这里演示因为网络原因我只给大家导入一幅小图。
相关文章
- 三角洲云游戏网页版极速畅玩-三角洲云游戏一键秒玩入口 11-02
- Windows 11 如何永久禁用会自动重启的 SearchHost.exe? 11-02
- 漫蛙manwa2链接入口-漫蛙manwa2网页直达入口 11-02
- jm漫画天堂-禁漫成人隐藏入口 11-02
- AO3镜像站合集-10个实测可用AO3入口网址速存 11-02
- pixiv网页版手机入口-pixiv手机网页登录入口 11-02