刚学flash脚本,制作了一个打字游戏,经过朋友使用后感觉不错,就把它发布出来,与大家共享。
经过了1.1、1.2测试版之后,终于迎来了2.0正式版,代码和布局进行了优化。增加了一些功能。
2.1版加入了updateAfterEvent()使得运行更流畅,字迹更清晰。加入了最大速限制,并且使速度以
N的平方根增加,以免速度过快。在此感谢习惯有你和海鸥提供宝贵意见,并且希望大家多多支持。
关键代码参考:
onClipEvent(load)
{right=0;wrong=0;time=60;
function timer(){time++;}
setInterval(timer,1000);}
onClipEvent (keyDown)
{
n=0;removeMovieClip(_root.start);
if(Number(_root.sudu.text)>0){
if(Number(_root.sudu.text)>=20)_root.sudu.text="20";
keycode=chr(Key.getCode());
if(keycode<="Z"&&keycode>="A"){
for(i=0;i<=3;i++)
{
loves=_parent.love[i]
if(loves.word.text==keycode)
{
if(right%2==0){ fly=1;
duplicateMovieClip(loves,"copy1",40);
duplicateMovieClip(_root.angle1,"anglex",42);
_root.anglex._x=_root.copy1._x;
_root.anglex._y=_root.copy1._y;
removeMovieClip(_root.copy2);
removeMovieClip(_root.angley);}
else{fly=2;
duplicateMovieClip(loves,"copy2",41);
duplicateMovieClip(_root.angle2,"angley",42);
_root.angley._x=_root.copy2._x;
_root.angley._y=_root.copy2._y;
removeMovieClip(_root.copy1);
removeMovieClip(_root.anglex);}
loves.word.text=chr(random(26)+65);
loves._y=540;
type=new Sound()
type.attachSound("type");
type.start();
right++;
}
else{n++;if(n==4){wrong++;
cuowu=new Sound();
cuowu.attachSound("wrong");
cuowu.start();}
}
}}
if(right==0&&right!=0)
{
_root.sudu.text=Number(_root.sudu.text)+1;
if(right ==0)
{goodjob1=new Sound();
goodjob1.attachSound("goodjob1")
goodjob1.start();
}
if(rightP==0)
{goodjob2=new Sound()
goodjob2.attachSound("goodjob2")
goodjob2.start();}
}}
if(right==1000)getURL("",_blank);
}
onClipEvent(enterFrame)
{
if(fly==1){
_root.anglex._x+=30;
_root.anglex._y-=30;
_root.copy1._x=_root.anglex._x
_root.copy1._y=_root.anglex._y
}
if(fly==2){
_root.angley._x-=30;
_root.angley._y-=30;
_root.copy2._x=_root.angley._x
_root.copy2._y=_root.angley._y
}
r="正确个数"+right;
w="/n/n错误个数"+wrong;
rate="/n/n正确率"+int(100*right/(right+wrong))+"%";
geshu="/n/n每分钟"+int(60*right/time)+"个"
_root.total.text=r+w+rate+geshu;
}