画线实现蜘蛛丝的动态更新 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

    动态

    以前个人网上的一个点辍,用画线实现的,希望给有想象力的同志一点启发,抛砖先

    (1)先建三个MC,如下:

   

    screen.width-333)this.width=screen.width-333" border=0>

    一个是spider_mc,画一个蜘蛛,像样点就算了,呵呵!一个是net_mc一个网,当背景用的,没有用!最后一个是空的MC,叫line_mc,用来画线的.

    (2)回到场景,建三个层如下:

   

    screen.width-333)this.width=screen.width-333" border=0>

    最底一个叫NET,用来放背景net 的,把net拉进去;中间一个层叫line,用来放line_mc的,把line_mc拉进来,并给这个剪辑命名line_mc;最后一个当然是放spider_mc 的啦,有点废话了!

    (3)好,最后关键一步,多建一个action层,写上如下代码:

    speed=10;

    spider_mc.onEnterFrame=function(){

    dx=_root._xmouse-this._x;

    dy=_root._ymouse-this._y;

    p=Math.atan(dy/dx)*180/Math.PI;

    rota=(dx>0)?(90+p):(270+p);

    this._x+=dx/speed;

    this._rotation=rota;

    this._y+=dy/speed;};

    line_mc.onEnterFrame=function(){

    this.clear();

    this.moveTo(0,0);

    this.lineStyle(1,0xffffff,100);

    this.lineTo(_root.spider_mc._x,_root.spider_mc._y);

    };

    结束

最新文章