【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《《让代码飞》教程网打地鼠游戏主面板代码》,欢迎阅读!
《让代码飞》教程网打地鼠游戏主面板代码 import flash.events.Event;
import flash.events.MouseEvent; import flash.text.TextField; import flash.text.TextFormat; stop();
var da:int = 0; var kou:int = 5;
var str:String = "您当前的得分是:"; var txt:TextField=new TextField(); var tf:TextFormat=new TextFormat(); var txt2:TextField=new TextField(); var tf2:TextFormat=new TextFormat(); tf2.color = 0xff0000; tf2.size = 36; txt2.width = 300; txt2.y = 100; txt2.x = 150;
txt2.selectable = false; txt2.height = 60;
var btn1:btn=new btn(); btn1.x = 220; btn1.y = 170; tf.size = 24; tf.color = 0xff;
txt.text = str + da.toString(); txt.setTextFormat(tf); addChild(txt); txt.width = 300;
txt.selectable = false;
var arr:Array=new Array(); for (var i:int=0; i<10; i++) {arr[i]=new mc(); var x1:int = i % 5; var y1:int = i / 5; arr[i].x = x1 * 100 + 65; arr[i].y = 280 + y1 * 80; arr[i].stop(); arr[i].mouseChildren = false; arr[i].addEventListener(MouseEvent.MOUSE_DOWN,onmousedown); addChild(arr[i]); }
var kk = setInterval(up,1500);
addEventListener(Event.ENTER_FRAME,onenterframe);
function onenterframe(e:Event) { chui_mc.x = mouseX + 90; chui_mc.y = mouseY; for (var i:int=0; i<10; i++) {if (arr[i].currentFrame == 28) {kou -= 1; if (kou==0) {txt2.text = "GameOver"; txt2.setTextFormat(tf2); addChild(txt2); clearInterval(kk); addChild(btn1); removeEventListener(Event.ENTER_FRAME,onenterframe); } } } }
addChild(chui_mc);
function onmousedown(e:MouseEvent) { chui_mc.play(); if (e.target.currentFrame > 3 && e.target.currentFrame < 27) { e.target.gotoAndPlay(31); da += 1; txt.text = str + da; txt.setTextFormat(tf); } }
function up() { var r:int = Math.random() * 10; arr[r].gotoAndPlay(1); }
btn1.addEventListener(MouseEvent.CLICK,onclick) function onclick(e:MouseEvent){ kou=0 da=0 addEventListener(Event.ENTER_FRAME,onenterframe)
kk=setInterval(up,1500) removeChild(txt2); removeChild(btn1); txt.text = str + da; txt.setTextFormat(tf); }
本文来源:https://www.wddqxz.cn/926c1bde8762caaedc33d438.html