注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

《电脑之家》

请点击:“日志”浏览电脑知识

 
 
 

日志

 
 

特效源码--接上页  

2011-01-12 00:28:57|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

 

提示:喜欢的朋友请点击下面“引用”把此博文搬回你家,再将不喜欢的部分删除,然后,就变成自己的啦~

【接上页】

1:立体效果方格网

function addStar()
{
    star = attachMovie("dot", "d" + count, count++);
    star.x = blue.oldx;
    star.y = blue.oldy;
    star.z = blue.oldz;
    star.onEnterFrame = starMove;
} // End of the function
function starMove()
{
    var _loc1 = this;
    var _loc2 = red.x - _loc1.x;
    var _loc3 = red.y - _loc1.y;
    var _loc3 = red.z - _loc1.z;
    var distSQ = _loc2 * _loc2 + _loc3 * _loc3 + _loc3 * _loc3;
    var force = 15000 / distSQ;
    var zangle = Math.atan2(_loc3, _loc2);
    _loc1.vx = _loc1.vx + Math.cos(zangle) * force;
    _loc1.vy = _loc1.vy + Math.sin(zangle) * force;
    var yangle = Math.atan2(_loc3, _loc2);
    _loc1.vz = _loc1.vz + Math.sin(yangle) * force;
    _loc1.vy = _loc1.vy + grav;
    _loc1.x = _loc1.x + _loc1.vx;
    _loc1.y = _loc1.y + _loc1.vy;
    _loc1.z = _loc1.z + _loc1.vz;
    if (_loc1.y > 200)
    {
        _loc1.y = 200;
        _loc1.vy = _loc1.vy * -7.000000E-001;
    } // end if
    if (_loc1.z < -fl)
    {
        _loc1._visible = false;
    } // end if
    if (_loc1.age++ > 200)
    {
        _loc1.removeMovieClip();
        return;
    } // end if
    var scale = fl / (fl + _loc1.z + cz);
    _loc1._x = cx + _loc1.x * scale;
    _loc1._y = cy + _loc1.y * scale;
    _loc1._xscale = _loc1._yscale = scale * 100;
} // End of the function
stop ();
cx = 350;
cy = 200;
cz = 50;
fl = 300;
createEmptyMovieClip("lines", 10000000);
createEmptyMovieClip("lines2", 10000001);
lines.lineStyle(1, 16777215, 10);
for (xa = -10; xa < 11; xa++)
{
    x = xa * 100;
    y = 200;
    scale = fl / (fl - 50 + cz);
    x1 = x * scale + cx;
    y1 = y * scale + cy;
    lines.moveTo(x1, y1);
    scale = fl / (fl + 2000 + cz);
    x2 = x * scale + cx;
    y2 = y * scale + cy;
    lines.lineTo(x2, y2);
} // end of for
for (ya = 0; ya < 20; ya++)
{
    y = 200;
    z = ya * 100;
    scale = fl / (fl + z + cz);
    x1 = 1000 * scale + cx;
    y1 = y * scale + cy;
    lines.moveTo(x1, y1);
    x2 = -1000 * scale + cx;
    lines.lineTo(x2,y1);
} // end of for
grav = 1.200000E-001;
baseSpeed = -1.000000E-002;
red.y = -100;
blue.y = -100;
onEnterFrame = function ()
{
    baseSpeed = (_xmouse - 350) * 2.000000E-004;
    baseAngle = baseAngle + baseSpeed;
    red.x = Math.cos(baseAngle) * 200;
    red.z = Math.sin(baseAngle) * 200 + 200;
    blue.x = -red.x;
    blue.z = -(red.z - 200) + 200;
    var _loc1 = fl / (fl + red.z + cz);
    red._x = cx + red.x * _loc1;
    red._y = cy + red.y * _loc1;
    red._xscale = red._yscale = _loc1 * 100;
    red.swapDepths(1000000000 - red.z * 100);
    lines2.clear();
    lines2.lineStyle(1, 255, 30);
    lines2.moveTo(red._x, red._y);
    lines2.lineTo(red._x, 200 * _loc1 + cy);
    _loc1 = fl / (fl + blue.z + cz);
    blue.oldx = blue.x;
    blue.oldy = blue.y;
    blue.oldz = blue.z;
    blue._x = cx + blue.x * _loc1;
    blue._y = cy + blue.y * _loc1;
    blue._xscale = blue._yscale = _loc1 * 100;
    blue.swapDepths(1000000000 - blue.z * 100);
    lines2.lineStyle(1, 16711680, 30);
    lines2.moveTo(blue._x, blue._y);
    lines2.lineTo(blue._x, 200 * _loc1 + cy);
    if (getTimer() - start > 300)
    {
        addStar();
        start = getTimer();
    } // end if
};

  评论这张
 
阅读(279)| 评论(1)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017