这是flash贪吃蛇游戏中食物的代码?拜托了各位 谢谢

onEnterFrame=function(){if(this.hitTest(_root.st.z)){this._x=20*random(27)+10this._y=... onEnterFrame=function(){ if (this.hitTest(_root.st.z)){ this._x=20*random(27)+10 this._y=random(20)*20+10 _root.cd++ _root.fs+=20 } } cd好像是蛇的长度,fs代表分数,st代表蛇头,那位可以大体的给我解释一下? 展开
 我来答
温柔攻421q
2014-08-21 · TA获得超过198个赞
知道答主
回答量:182
采纳率:80%
帮助的人:59.5万
展开全部
stop();//停止播放影片 init(); mc1._x = 300; mc1._y = 400+mcMain._height; for (i=2; i<=tc; i++) { mcMain.duplicateMovieClip("mc"+i,100+i); tempMc = eval("mc"+i); tempMc._x = 300; tempMc._y = 400+(i*mcMain._height); } fnDisplayApple(); mc1.onKeyDown = function() { if (gameOver == 0) { dir = Key.getCode(); } }; mc1.onEnterFrame = function() { if (gameOver == 0) { timer(); //dir = Key.getCode(); switch (dir) { case 37 : mc1._x -= wid; mc1._rotation = -90; break; case 39 : mc1._x += wid; mc1._rotation = 90; break; case 38 : mc1._y -= wid; mc1._rotation = 0; break; case 40 : mc1._y += wid; mc1._rotation = 180; break; default : mc1._y -= wid; mc1._rotation = 0; break; } dirOld = dir; if (mc1.hitTest(touch1)) { score++; txtScore.text = score; tc++; mcMain.duplicateMovieClip("mc"+tc, 100+tc); eval("mc"+tc).onEnterFrame = aa; touch1._y = 2000; dispA = setInterval(fnDisplayApple, 300); } else { for (i=2; i<=tc; i++) { tempMc = eval("wall"+(i-1)); if (mc1.hitTest(tempMc)) { fnGameOver(4); break; } tempMc = eval("mc"+(i+1)); if (mc1.hitTest(tempMc)) { fnGameOver(4); break; } } } } }; function aa() { if (gameOver == 0) { objNum = this._name.substr(2); this._x = eval("mc"+(objNum-1))._x; this._y = eval("mc"+(objNum-1))._y; this._rotation = eval("mc"+(objNum-1))._rotation; } } for (i=2; i<=tc; i++) { eval("mc"+i).onEnterFrame = aa; } OldTime = getTimer(); function timer() { newTime = getTimer(); if (newTime-oldTime>1000) { sec++; if (sec>=60) { min++; sec = 0; fnGameOver(5); } var ts = "0"+sec; var tm = "0"+min; sec = ts.substr(-2); min = tm.substr(-2); txtTime.text = min+":"+sec; sec = parseInt(ts.substr(-2), 10); min = parseInt(tm.substr(-2), 10); oldTime = getTimer(); } } function fnGameOver(val) { clearInterval(dispA); gameOver = 1; mcMessages.gotoAndStop(val); } function fnDisplayApple() { ranX = random((wall2._x-wall2._width/2)-(wall4._x+wall4._width/2)-touch1._width)+touch1._width/2+wall4._x+wall4._width/2; ranY = random((wall3._y-wall3._height/2)-(wall1._y+wall1._height/2)-touch1._height)+touch1._height/2+wall1._y+wall1._height/2; touch1._x = ranX; touch1._y = ranY; clearInterval(dispA); } function init() { Key.addListener(mc1); min = 0; sec = 0; txtTime.text = "00:00"; score = 0; wid = mcMain._height+1; tc = 5; gameOver = 0; dir = 38; txtScore.text = 0; mcMain.duplicateMovieClip("mc", 1); for (i=1; i<=4; i++) { eval("wall"+i).swapDepths(1000+i); } } 问题补充:就是对源程序的注释,希望写得清楚一点啊,每一个函数什么意思。真的很急啊,大家快啊,谢谢
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式