游戏效果
新建Fla,在第一帧F9添加代码即可。
代码如下 | |
var arr:Array = new Array(); var time:uint=0; var angle:Number=0; var zfun; [SWF(width=800, height=465,backgroundColor=0xffffff, frameRate=24)] this.addEventListener(Event.ENTER_FRAME,function(event){ time++; angle+=0.1; if(time>=13){ var tf:TextField = addChild(new TextField()) as TextField; zfun = function(){time = 0,tf.htmlText ='<font size="'+String(Math.round(Math.random()*35)+15)+'" color="#'+String(Math.random()*16777215)+'">'+ String.fromCharCode(int(Math.random()*26+65).toString())+'</font>',tf.x = Math.random()*-760+780,tf.y = -10,tf.name = (Math.random()*-10+5).toString(),arr.unshift(tf)}.apply(); } for(var i:Number = arr.length-1;i>=0;i--){ zfun =function(){arr[i].y+=3,arr[i].x+= Math.sin(angle)*int(arr[i].name)}.apply(); if(arr[i].y>=stage.stageHeight){ zfun =function(){removeChild(arr[i]),arr.splice(i,1)}.apply(); break; } } }); stage.addEventListener(KeyboardEvent.KEY_DOWN,function(event){ for(var i:Number = arr.length-1;i>=0;i--){ if(arr[i].text==String.fromCharCode(event.keyCode)){ zfun =function(){removeChild(arr[i]),arr.splice(i,1)}.apply(); break; } } }); |
时间: 2024-09-21 04:25:18