Flash模仿《金山打字顺风车》(打字游戏)源代码。

一个简单的Flash打字游戏。

上一页/下一页

查看(142)/评论(3)/评分(5/0)

代码:

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

打字游戏-V1.0

日期:2007年9月24日

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

已定义变量

-

*/

fscommand(“全屏”,真);

var Bring _ num:Number = 0;

var Bring _ maxnum:Number = 20;

var Grade _ num:Number = 1;

var Grade _ bring:Number = 100;

var Move _ speed:Number = 2;

var Bring _ speed:Number = 0;

var Press _ num:Number = 0;

var Right _ num:Number = 0;

var Loss _ num:Number = 0;

var Grade _ Boolean:Boolean = false;

var Interval _ num:Number = 0;

var监听器:Object = new Object();

var Addsound:Sound = new Sound();

var add blast _ MC:Object = new Object();

var Time _ m:Number = 0;

var Time _ s:Number = 1;

var Hide _ id:Number;

/*

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Bring_word函数:随机生成字符。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

*/

函数Bring_word() {

var color_array:Array =新数组(0xffffff,0x9B4A8B,0xE0C0DB,0xAC285E,0x235CB1,0x379D37,0xb 1A323);

var txt style:text format = new text format();

txtstyle.bold = true

txt style . font = "π";

txtstyle.size = 20

txt style . color = color _ array[random(7)];

_root。bring _ num++;

if (_root。Bring _ num & gt=Bring_maxnum) {

_root。bring _ num = 0;

}

开关(随机(2)) {

案例0:

txt = random(26)+97;

打破;

案例1:

txt = random(10)+48;

打破;

}

_ root . create textfield(" txt "+_ root。带号码,根号码。Bring_num,random(Stage.width),-(random(200)+10),25,25);

这个["txt"+_root。Bring_num]。text = chr(txt);

这个["txt"+_root。Bring_num]。settext format(txt style);

}

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Interval_event()。初始化期间生成的字符数

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

*/

函数区间_事件(){

bring _ word();

interval _ num++;

if(时间间隔数& gt=3) {

clear Interval(Interval _ id);

}

}

var Interval _ id:Number = setInterval(Interval _ event,1000);

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Cyc_event下降函数

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

*/

函数cyc_event() {

函数_事件(){

for(var I = 0;我& lt= Bring _ maxnumi++) {

var n:Number = random(2)?-math . random()* 9:math . random()* 9;

_root["txt"+i]。_ y+= Move _ speed;

_root["txt"+i]。_ x+= n;

if (_root["txt"+i)。_ y & gt舞台.高度){

_root["txt"+i]。remove textfield();

bring _ word();

loss _ num++;

loss _ txt.text = Loss _ num

}

}

}

var cyc _ id:Number = setInterval(_ event,50);

}

cyc _ event();

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

监视器键盘

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

*/

Key.addListener(监听器);

Listener.onKeyDown = function() {

press _ num++;

//trace(Press _ num);

if (Grade_boolean) {

grade _ num++;

Grade _ boolean = false

Grade _ txt . text = " first "+Grade _ num+" off ";

move _ speed+= 2;

for(var I = 0;我& lt3;i++) {

bring _ word();

}

}

//trace(" Press _ num = "+Press _ num ");

for(I = 0;我& lt= Bring _ maxnumi++) {

if (_root["txt"+i)。text = = chr(key . getas CII()){

right _ num++;

addsound . attachsound(" Sound _ MC ");

addsound . start();

//_root.attachMovie("Blast_mc "," Addblast_mc ",_root.getNextHighestDepth(),{_x:_root["txt"+i])。_x,_y:_root["txt"+i]。_ y });

blast _ MC . play();

Blast_mc。_x = _root["txt"+i]。_ x;

Blast_mc。_y = _root["txt"+i]。_ y;

_root["txt"+i]。remove textfield();

bring _ word();

if(Right _ num & gt;= Grade _ bring and Right _ num % Grade _ bring = = 0){

Grade _ boolean = true

}否则{

Grade _ boolean = false

}

}

}

Right _ txt . text = String(Right _ num);

如果(按编号-右编号& gt0) {

wrong _ txt . text = String(Press _ num-Right _ num);

}否则{

Press _ num+= math . ABS(Press _ num-Right _ num);

}

};

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5

时间函数

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5

*/

函数时间事件(){

time _ s++;

if(Time _ s/60 & gt;1) {

time _ m++;

time _ s = 1;

}

Time _ txt . text = Time _ m+":"+Time _ s % 60;

}

setInterval(Time_event,1000);

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

介绍功能

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

*/

var new menu:context menu = new context menu();

new menu . hidebuiltitems();

this.menu = newmenu

new menu . custom items . push(new context menuitem("作者:Edward.yang ",by _ event));

new menu . custom items . push(new context menuitem(" QQ:77839683 ",getqq));

new menu . custom items . push(new context menuitem(" exit ",exit_event,true));

函数出口事件(){

fscommand("quit "," ");

}

函数by_event() {

Hide_id = setInterval(hide_by,5000);

by _ MC . gotoandstop(2);

by_mc。_ alpha = 0;

by_mc.onEnterFrame = function() {

这个。_ alpha+=(100-这个。_ alpha)/8;

这个。_ x+= (Stage.width/2-this。_ x)/8;

这个。_ y+= (Stage.height/2-this。_ y)/8;

//trace(这个。_ alpha);

如果(这个。_ alpha & gt=100) {

删除by _ mc.onEnterFrame

}

};

}

函数hide_by() {

by_mc.onEnterFrame = function() {

这个。_ alpha-= 8;

//trace(这个。_ alpha);

如果(这个。_ alpha & lt=0) {

this . gotoandstop(1);

clearInterval(Hide _ id);

删除by _ mc.onEnterFrame

}

};

}

函数getqq() {

getURL("腾讯://message/?uin = 77839683”);