• 文字广告位
  • 文字广告位
  • 文字广告位
您现在的位置: 站长手册 >> 特效代码 >> 鼠标类 >> 正文
站内搜索
Google
[图文]跟随鼠标的吃豆游戏
          ★★★★   

跟随鼠标的吃豆游戏

雅虎收藏夹 百度收藏 Google书签 Yahoo书签 新浪ViVi 搜狐网摘 365Key网摘 天极网摘 diglog 和讯网摘 POCO网摘 YouNote网摘 博拉网 天下图摘 Del.icio.us digg reddit spurl BlinkList blogmarks
人气: 来源:网络 作者:佚名 所属栏目:鼠标类 [切换到繁體中文]
介绍:鼠标移动时会在后面出现一连串的小豆,超过一定数目后小豆会被一个一个吃掉。

演示:

[Ctrl+A全选 提示:你可先修改部分代码,再按运行]

下面教你如何应用此特效:
 --------------------------------------------------------------------------------------
  需要在<body 这里>加入的代码:ONMOUSEMOVE="update()"
 --------------------------------------------------------------------------------------
以下代码加到<head>…</head>中
以下代码加到<body>…</body>中
<SCRIPT LANGUAGE = "Javascript1.2">
<!--
ammount = 10;
times = 1;
wait = 0;
done = false;
x = new Array();
y = new Array();
temp = 0;
waitUntil = 10;

pillSrc = "/texiao/zzsc_demo/20070604212223699.gif";
pacCESrc = "/texiao/zzsc_demo/PacCE.gif";
pacOESrc = "/texiao/zzsc_demo/PacOE.gif";
pacCWSrc = "/texiao/zzsc_demo/PacCW.gif";
pacOWSrc = "/texiao/zzsc_demo/PacOW.gif";

for (i = 1; i <= ammount; i++)
  document.write('<DIV ID = "pill' + i + '" STYLE = "visibility: hidden; position: absolute"><IMG NAME = "pic' + i + '" SRC = "' + pillSrc + '"></DIV>');

pillW = document.pic1.width;
pillH = document.pic1.height;

document.write('<DIV ID = "pacCE" STYLE = "visibility: hidden; position: absolute"><IMG NAME = "pac1E" SRC = "' + pacCESrc + '"></DIV>');
document.write('<DIV ID = "pacOE" STYLE = "visibility: hidden; position: absolute"><IMG NAME = "pac2E" SRC = "' + pacOESrc + '"></DIV>');
document.write('<DIV ID = "pacCW" STYLE = "visibility: hidden; position: absolute"><IMG NAME = "pac1W" SRC = "' + pacCWSrc + '"></DIV>');
document.write('<DIV ID = "pacOW" STYLE = "visibility: hidden; position: absolute"><IMG NAME = "pac2W" SRC = "' + pacOWSrc + '"></DIV>');

showPacC = document.getElementById("pacCE").style;
showPacO = document.getElementById("pacOE").style;

pacCWidth = document.pac1E.width;
pacCHeight = document.pac1E.height;
pacOWidth = document.pac2E.width;
pacOHeight = document.pac2E.height;

function pacPicC()
{
  temp = place + 1;
  if (temp > ammount)
    temp = 1;
  if (x[temp] >= x[place])
  {
    showPacC = document.getElementById("pacCE").style;
    xOff = 10;
  }
  else
  {
    showPacC = document.getElementById("pacCW").style;
    xOff = 23;
  }
}

function pacPicO()
{
  temp = place + 1;
  if (temp > ammount)
    temp = 1;
  if (x[temp] >= x[place])
  {
    showPacO = document.getElementById("pacOE").style;
    xOff = 10;
  }
  else
  {
    showPacO = document.getElementById("pacOW").style;
    xOff = 23;
  }
}

function update(e)
{
  wait++;
  if (wait == waitUntil)
  {
    if (times > ammount)
    {
      done = true;
      times = 1;
    }
    showPill = document.getElementById("pill" + times + "").style;
    x[times] = event.x + document.body.scrollLeft - (pillW / 2);
    showPill.left = x[times];
    y[times] = event.y + document.body.scrollTop - (pillH / 2);
    showPill.top = y[times];
    showPill.visibility = "visible";
    if (done)
    {
      showPacC.visibility = "hidden";
      place = times + 1;
      if (place > ammount)
        place = 1;
      pacPicO();
      showPacO.left = x[place] - pacOWidth + xOff;
      showPacO.top = y[place] - (pacOHeight / 2) + 3;
      showPacO.visibility = "visible";
    }  
    times++;
    wait = 0;
  }
  else if (wait == waitUntil / 2 && done)
  {
    showPacO.visibility = "hidden";
    if (place > ammount)
      place = 1;
    pacPicC();
    showPacC.left = x[place] - pacCWidth + xOff;
    showPacC.top = y[place] - (pacCHeight / 2) + 3;
    showPacC.visibility = "visible";
  }
}
//-->
</SCRIPT>

  • 上一个特效:
  • 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    姓 名: *(必填项) ·注册用户·
    Email: QQ号:
    评 分: 1分 2分 3分 4分 5分
    • 您可以发表评论支持你喜欢的文章。
    • 请遵守《互联网电子公告服务管理规定》
    • 请遵守中华人民共和国各项有关法律法规。
    • 严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
    • 评论人需对自己在使用评论过程中的行为承担法律责任。
    • 本站管理员有权保留或删除评论内容。
    • 评论内容只代表个人观点,与本网站立场无关。
    站内特效搜索
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | | 京ICP备 05004866号 |
    版权所有 2007-2008 站长手册 WWW.ZZSC.ORG 业务联系 zzsc.org#gmail.com