互動(dòng)媒體制作實(shí)驗(yàn)報(bào)告_第1頁(yè)
互動(dòng)媒體制作實(shí)驗(yàn)報(bào)告_第2頁(yè)
互動(dòng)媒體制作實(shí)驗(yàn)報(bào)告_第3頁(yè)
互動(dòng)媒體制作實(shí)驗(yàn)報(bào)告_第4頁(yè)
互動(dòng)媒體制作實(shí)驗(yàn)報(bào)告_第5頁(yè)
已閱讀5頁(yè),還剩74頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

77/79上海建橋?qū)W院本科實(shí)驗(yàn)報(bào)告課程名稱(chēng):互動(dòng)媒體制作學(xué)號(hào):姓名:專(zhuān)業(yè):數(shù)字媒體藝術(shù)班級(jí):指導(dǎo)教師:課內(nèi)實(shí)驗(yàn)?zāi)夸浖俺煽?jī)序號(hào)實(shí)驗(yàn)名稱(chēng)頁(yè)碼成績(jī)1交互事件動(dòng)畫(huà)(星星亮滿(mǎn)天)12文字回合類(lèi)游戲制作43找茬類(lèi)小游戲74碰撞類(lèi)游戲制作11信息技術(shù)學(xué)院2012年12月1日上海建橋?qū)W院實(shí)驗(yàn)報(bào)告課程名稱(chēng):互動(dòng)媒體制作實(shí)驗(yàn)類(lèi)型:驗(yàn)證型實(shí)驗(yàn)項(xiàng)目名稱(chēng):交互事件動(dòng)畫(huà)(星星亮滿(mǎn)天)實(shí)驗(yàn)地點(diǎn):多媒體機(jī)房實(shí)驗(yàn)日期:2013年3月7日實(shí)驗(yàn)?zāi)康暮鸵笫煜さ倪\(yùn)用;鞏固AS3.0的程序結(jié)構(gòu)和基本語(yǔ)法;能夠創(chuàng)建和調(diào)用系統(tǒng)函數(shù);能夠熟練運(yùn)用程序基本結(jié)構(gòu);制作滿(mǎn)足相應(yīng)指標(biāo)要求的正確運(yùn)行的小游戲;實(shí)驗(yàn)內(nèi)容和原理使用顯示對(duì)象、對(duì)象點(diǎn)擊事件、三大元件等編寫(xiě)交互功能程序的基本結(jié)構(gòu)包括:順序結(jié)構(gòu)、選擇結(jié)構(gòu)、循環(huán)結(jié)構(gòu)事件函數(shù):MouseEvent事件類(lèi)時(shí)間函數(shù):Timer類(lèi)主要儀器設(shè)備或環(huán)境PC機(jī);Flashcs5.5(或以上);Photoshopcs5(或以上);移動(dòng)終端5套。操作方法與實(shí)驗(yàn)步驟1、確定游戲的主題(名稱(chēng)、色彩配置、主題思想、使用方法等)名稱(chēng):星星亮滿(mǎn)天色彩配置:深邃的天空+顏色隨機(jī)的星星主題思想:在背景天空區(qū)域,左鍵單擊星星出現(xiàn),并且顏色隨機(jī)使用方法:鼠標(biāo)左鍵單擊2、確定游戲的設(shè)計(jì)流程圖3、游戲素材的采集、導(dǎo)入或制作導(dǎo)入圖片bg,并轉(zhuǎn)成元件導(dǎo)入圖片星光,并制作成動(dòng)畫(huà)4、關(guān)鍵的操作步驟(含主要代碼)及技巧星光轉(zhuǎn)換成元件,并制作動(dòng)畫(huà),達(dá)到星星從大到小,從小到大的變化。然后將此元件再次轉(zhuǎn)換,并再次制作動(dòng)畫(huà),共5幀,每幀星星顏色不一樣。在bg上的天空上制作一個(gè)遮罩層mc,并對(duì)mc添加一個(gè)鼠標(biāo)監(jiān)聽(tīng)。mc.addEventListener(MouseEvent.CLICK,fl_MouseClickHandler_2);functionfl_MouseClickHandler_2(event:MouseEvent):void{ varmystar:star=newstar(); mystar.x=mouseX; mystar.y=mouseY; //改大小/顏色 mystar.stop(); varrandomNum:int=Math.floor(Math.random()*5+1); mystar.width=mystar.height=Math.random()*60+30; mystar.gotoAndStop(randomNum); addChild(mystar); trace("已單擊鼠標(biāo)");}實(shí)驗(yàn)結(jié)果注:可用貼圖的方式1、主要使用的AS3.0的知識(shí)點(diǎn)添加鼠標(biāo)監(jiān)聽(tīng)、實(shí)例對(duì)象顯示在鼠標(biāo)點(diǎn)擊的位置(mystar.x=mouseX;mystar.y=mouseY;)、數(shù)學(xué)函數(shù)(隨機(jī)數(shù)、向下取整)、gotoAndStop2、小游戲的效果(至少給出3個(gè),含制作過(guò)程及結(jié)果)實(shí)驗(yàn)總結(jié)注:包括制作過(guò)程中出現(xiàn)的問(wèn)題,實(shí)驗(yàn)心得體會(huì)及改進(jìn)意見(jiàn)等在老師的帶領(lǐng)下完成了此次小游戲,初次體驗(yàn)到Flash的神奇,特別是隨機(jī)數(shù)的出現(xiàn)。在這種濃烈的興趣下,我將更認(rèn)真的學(xué)習(xí)Flash。上海建橋?qū)W院實(shí)驗(yàn)報(bào)告課程名稱(chēng):互動(dòng)媒體制作實(shí)驗(yàn)類(lèi)型:設(shè)計(jì)型實(shí)驗(yàn)項(xiàng)目名稱(chēng):文字回合類(lèi)游戲制作(面向過(guò)程及時(shí)間函數(shù))實(shí)驗(yàn)地點(diǎn):多媒體機(jī)房實(shí)驗(yàn)日期:2013年3月21日實(shí)驗(yàn)?zāi)康暮鸵箪柟堂嫦驅(qū)ο缶幊痰南嚓P(guān)概念;構(gòu)造函數(shù)的創(chuàng)建和使用;事件處理機(jī)制及Event類(lèi)的創(chuàng)建、使用(事件偵聽(tīng)器);能夠熟練運(yùn)用鼠標(biāo)事件;制作滿(mǎn)足要求的動(dòng)畫(huà)效果;實(shí)驗(yàn)內(nèi)容和原理使用事件驅(qū)動(dòng)編寫(xiě)AS3.0應(yīng)用程序(物體移動(dòng)等的動(dòng)畫(huà)效果)鼠標(biāo)事件:CLICK、MOUSE_MOVE、MOUSE_OVER、MOUSE_OUT、MOUSE_WHEEL等鍵盤(pán)事件:KeyboardEvent.KEY_DOWN(UP)等時(shí)間函數(shù):TimerEvent.TIMER、TimerEvent.TIMER_COMPLETE主要儀器設(shè)備或環(huán)境PC機(jī);Flashcs5.5(或以上);Photoshopcs5(或以上);移動(dòng)終端5套。操作方法與實(shí)驗(yàn)步驟1、確定作品的主題(名稱(chēng)、色彩配置、主題思想、使用方法等)名稱(chēng):勇者斗惡龍主題思想:為了描寫(xiě)戰(zhàn)斗,對(duì)勇者與惡龍?jiān)O(shè)置特性,如名字,攻擊力,防御力以及速度,運(yùn)行游戲,出現(xiàn)打斗文字。使用方法:結(jié)果顯示在輸入框里2、主題作品的設(shè)計(jì)運(yùn)行游戲后,勇者與惡龍輪流發(fā)動(dòng)攻擊,最后得出勝負(fù)。3、素材的導(dǎo)入或制作沒(méi)有素材的導(dǎo)入4、關(guān)鍵的操作步驟(含主要代碼)及技巧varhero:Object=newObject();varmonster:Object=newObject();="勇者";hero.HP=500;hero.ATT=90;hero.DEF=88;hero.AGI=60;hero.skill1="普通攻擊";hero.skill2="飛刃閃";hero.skill3="極光劍";="惡龍";monster.HP=1000;monster.ATT=120;monster.DEF=100;monster.AGI=22;monster.skill1="攻擊";monster.skill2="龍尾擊";monster.skill3="毀滅光線(xiàn)";vartimer:Timer=newTimer(1000);timer.addEventListener(TimerEvent.TIMER,round)timer.start();functionwhoAttacks(a:Object,b:Object):Array{ returna.AGI*Math.random()>b.AGI*Math.random()?[a,b]:[b,a];}functionround(e:TimerEvent):void{ vardamage:Number; varskillIndex:uint; varroundFight:Array=whoAttacks(hero,monster); varattacker:Object=roundFight[0]; vardefender:Object=roundFight[1]; damage=attacker.ATT*Math.random()-defender.DEF*Math.random(); if(damage<=0){ damage=0; }else{ damage=Math.ceil(damage); } defender.HP-=damage; if(damage<attacker.ATT/3){ skillIndex=1; }elseif(damage<attacker.ATT*2/3){ skillIndex=2; }else{ skillIndex=3; } trace(+"向"++"發(fā)動(dòng)了"+attacker["skill"+skillIndex]+","++"損失了"+damage+"點(diǎn)HP!"); if(defender.HP<=0){ trace(+"終于支持不住,倒下了!\n"++"取得了勝利!"); timer.removeEventListener(TimerEvent.TIMER,round); trace("\nGameOver"); return; } trace(+"HP:"+hero.HP+"\t"++"HP:"+monster.HP);}實(shí)驗(yàn)結(jié)果注:可用貼圖的方式1、主要使用的知識(shí)點(diǎn)使用事件驅(qū)動(dòng)編寫(xiě)AS3.0應(yīng)用程序(物體移動(dòng)等的動(dòng)畫(huà)效果)鼠標(biāo)事件:CLICK、MOUSE_MOVE、MOUSE_OVER、MOUSE_OUT、MOUSE_WHEEL等鍵盤(pán)事件:KeyboardEvent.KEY_DOWN(UP)等時(shí)間函數(shù):TimerEvent.TIMER、TimerEvent.TIMER_COMPLETE2、作品的效果圖(至少給出3個(gè),含制作過(guò)程及結(jié)果)實(shí)驗(yàn)總結(jié)注:包括制作過(guò)程中出現(xiàn)的問(wèn)題,實(shí)驗(yàn)心得體會(huì)及改進(jìn)意見(jiàn)等大體上了解到我們平常玩的回合游戲的制作過(guò)程,很有趣,我很喜歡這個(gè)。不過(guò)我想要是加上圖片和效果的話(huà),難度會(huì)提升很多。上海建橋?qū)W院實(shí)驗(yàn)報(bào)告課程名稱(chēng):互動(dòng)媒體制作實(shí)驗(yàn)類(lèi)型:設(shè)計(jì)型實(shí)驗(yàn)項(xiàng)目名稱(chēng):找茬類(lèi)事件點(diǎn)擊類(lèi)小游戲?qū)嶒?yàn)地點(diǎn):多媒體機(jī)房實(shí)驗(yàn)日期:2013年4月15日實(shí)驗(yàn)?zāi)康暮鸵箪柟藺S3.0中核心類(lèi)及顯示對(duì)象的相關(guān)概念;學(xué)會(huì)MovieClip類(lèi)、Sprite類(lèi)的創(chuàng)建及使用;學(xué)會(huì)AS3.0中創(chuàng)建動(dòng)畫(huà)的幾種方式;能夠熟練運(yùn)用顯示對(duì)象的屬性;能夠熟練運(yùn)用timer類(lèi)創(chuàng)建動(dòng)畫(huà)(效果);制作滿(mǎn)足相應(yīng)要求的交互動(dòng)畫(huà);實(shí)驗(yàn)內(nèi)容和原理確定內(nèi)容健康的主題相關(guān)素材的準(zhǔn)備制作交互動(dòng)畫(huà)的流程圖(分鏡頭腳本)運(yùn)用Timer類(lèi)控制顯示對(duì)象的屬性來(lái)制作交互動(dòng)畫(huà)主要儀器設(shè)備或環(huán)境PC機(jī);Flashcs5(或以上);Photoshopcs5(或以上);移動(dòng)終端5套;數(shù)碼照相機(jī)1臺(tái);數(shù)碼攝像機(jī)1臺(tái);數(shù)位板1個(gè)。操作方法與實(shí)驗(yàn)步驟1、確定主題、設(shè)計(jì)流程圖主題:找茬游戲設(shè)計(jì)流程圖:2、游戲整體流程拆分游戲開(kāi)始初始化:開(kāi)始按鈕定義、開(kāi)始界面的設(shè)置、初始化數(shù)值游戲主題部分:添加三個(gè)文本框,一個(gè)計(jì)分?jǐn)?shù),一個(gè)倒計(jì)時(shí),一個(gè)統(tǒng)計(jì)剩余幾個(gè)錯(cuò)找到幾個(gè)錯(cuò)。添加Timer時(shí)間監(jiān)聽(tīng),用來(lái)倒計(jì)時(shí)。對(duì)cuowumian、cuo1、cuo2、cuo3.、cuo4.、cuo5添加鼠標(biāo)事件監(jiān)聽(tīng),MouseEvent.CLICK。游戲結(jié)束部分:移除游戲主體頁(yè)面上所有東西,移除監(jiān)聽(tīng)。根據(jù)找出的錯(cuò)的個(gè)數(shù)判斷是否通關(guān),并顯示在名為tf的文本框里。添加一個(gè)Restart按鈕,實(shí)現(xiàn)重玩的功能。3、三大游戲流程部分功能實(shí)現(xiàn)游戲開(kāi)始初始化、開(kāi)始界面的設(shè)置; myStartView=newStartView(); addChild(myStartView); myStartView.x=stage.stageWidth/2; myStartView.y=stage.stageHeight/2;游戲正式界面設(shè)置functiongameStart(){ scoreField=newTextField(); scoreFn(); addChild(scoreField); myGameView=newGameView(); addChild(myGameView); myGameView.x=stage.stageWidth/2; myGameView.y=stage.stageHeight/2; allTimer=10; timer=newTimer(1000,20); timer.addEventListener(TimerEvent.TIMER,timerFn); timer.start(); timeField=newTextField(); timeField.autoSize="center"; timeField.text="你還有"+allTimer+"秒"; timeField.x=400; addChild(timeField); myGameView.cuo1.stop(); myGameView.cuo2.stop(); myGameView.cuo3.stop(); myGameView.cuo4.stop(); myGameView.cuo5.stop(); myGameView.cuowumian.addEventListener(MouseEvent.CLICK,mianFn); myGameView.cuo1.addEventListener(MouseEvent.CLICK,cuo1Fn); myGameView.cuo2.addEventListener(MouseEvent.CLICK,cuo2Fn); myGameView.cuo3.addEventListener(MouseEvent.CLICK,cuo3Fn); myGameView.cuo4.addEventListener(MouseEvent.CLICK,cuo4Fn); myGameView.cuo5.addEventListener(MouseEvent.CLICK,cuo5Fn);}游戲結(jié)束functionendGame(){ removeChild(myGameView); removeChild(scoreField); removeChild(timeField); myGameView.cuowumian.removeEventListener(MouseEvent.CLICK,mianFn); tf=newTextField(); tf.width=300; if(score==5) { tf.text="恭喜你通關(guān)了"; } else { tf.text="很遺憾,請(qǐng)大俠重新來(lái)過(guò)"; } varformat:TextFormat=newTextFormat(); format.font="_sans"; format.color=0xFF0000; format.size=50; format.underline=true; tf.x=(stage.stageWidth-tf.width)/2; tf.y=(stage.stageHeight-tf.height)/2; tf.autoSize="center"; tf.defaultTextFormat=format; addChild(tf); myGameView.cuowumian.removeEventListener(MouseEvent.CLICK,mianFn); myEndBt=newButton(); addChild(myEndBt); myEndBt.label="Restart"; myEndBt.x=(stage.stageWidth-myEndBt.width)/2; myEndBt.y=300; myEndBt.addEventListener(MouseEvent.CLICK,restartFn);}4、游戲主體部分操作步驟(含主要代碼)及技巧importfl.controls.Button;importflash.events.MouseEvent;importflash.utils.Timer;importfl.motion.MotionEvent;importflash.text.TextField;importflash.display.Sprite;importflash.text.TextField;importflash.text.TextFormat;varallScore:int=5;varmyStartBt:Button;varmyStartView:StartView;varmyGameView:GameView;varmyEndBt:Button;vartimer:Timer;varscore:int;varscoreField:TextField;vartf:TextField;varallTimer:int;vartimeField:TextField;init();//游戲開(kāi)始初始化functioninit(){ //開(kāi)始按鈕定義 myStartBt=newButton(); addChild(myStartBt); myStartBt.x=(stage.stageWidth-myStartBt.width)/2; myStartBt.y=300; myStartBt.label="Start"; myStartBt.addEventListener(MouseEvent.CLICK,myStartBtFn); //開(kāi)始界面的設(shè)置; myStartView=newStartView(); addChild(myStartView); myStartView.x=stage.stageWidth/2; myStartView.y=stage.stageHeight/2; //數(shù)值初始化 score=0;}functionmyStartBtFn(e:MouseEvent){ removeChild(myStartBt); removeChild(myStartView); myStartBt.removeEventListener(MouseEvent.CLICK,myStartBtFn); gameStart();}//游戲正式界面設(shè)置functiongameStart(){ scoreField=newTextField(); scoreFn(); addChild(scoreField); myGameView=newGameView(); addChild(myGameView); myGameView.x=stage.stageWidth/2; myGameView.y=stage.stageHeight/2; allTimer=10; timer=newTimer(1000,20); timer.addEventListener(TimerEvent.TIMER,timerFn); timer.start(); timeField=newTextField(); timeField.autoSize="center"; timeField.text="你還有"+allTimer+"秒"; timeField.x=400; addChild(timeField); myGameView.cuo1.stop(); myGameView.cuo2.stop(); myGameView.cuo3.stop(); myGameView.cuo4.stop(); myGameView.cuo5.stop(); myGameView.cuowumian.addEventListener(MouseEvent.CLICK,mianFn); myGameView.cuo1.addEventListener(MouseEvent.CLICK,cuo1Fn); myGameView.cuo2.addEventListener(MouseEvent.CLICK,cuo2Fn); myGameView.cuo3.addEventListener(MouseEvent.CLICK,cuo3Fn); myGameView.cuo4.addEventListener(MouseEvent.CLICK,cuo4Fn); myGameView.cuo5.addEventListener(MouseEvent.CLICK,cuo5Fn);}functiontimerFn(e:TimerEvent){ allTimer--; timeField.text="你還有"+allTimer+"秒"; if(allTimer<0) { timer.stop(); timer.removeEventListener(TimerEvent.TIMER,timerFn); endGame(); }}functionmianFn(e:MouseEvent){ allTimer--;}functionscoreFn(){ scoreField.text="已找到"+String(score)+"錯(cuò),剩余"+String(allScore-score)+"處錯(cuò)"; scoreField.width=300;}functioncuo1Fn(e:MouseEvent){ myGameView.cuo1.removeEventListener(MouseEvent.CLICK,cuo1Fn); myGameView.cuo1.gotoAndStop(2); score++; scoreFn(); allTimer+=2; trace(score); if(score==5) { timer.stop(); endGame(); }}functioncuo2Fn(e:MouseEvent){ myGameView.cuo2.removeEventListener(MouseEvent.CLICK,cuo2Fn); myGameView.cuo2.gotoAndStop(2); score++; scoreFn(); allTimer+=2; trace(score); if(score==5) { timer.stop(); endGame(); }}functioncuo3Fn(e:MouseEvent){ myGameView.cuo3.removeEventListener(MouseEvent.CLICK,cuo3Fn); myGameView.cuo3.gotoAndStop(2); score++; scoreFn(); allTimer+=2; trace(score); if(score==5) { timer.stop(); endGame(); }}functioncuo4Fn(e:MouseEvent){ myGameView.cuo4.removeEventListener(MouseEvent.CLICK,cuo4Fn); myGameView.cuo4.gotoAndStop(2); score++; scoreFn(); allTimer+=2; trace(score); if(score==5) { timer.stop(); endGame(); }}functioncuo5Fn(e:MouseEvent){ myGameView.cuo5.removeEventListener(MouseEvent.CLICK,cuo5Fn); myGameView.cuo5.gotoAndStop(2); score++; scoreFn(); allTimer+=2; trace(score); if(score==5) { timer.stop(); endGame();}}//游戲結(jié)束functionendGame(){ removeChild(myGameView); removeChild(scoreField); removeChild(timeField); myGameView.cuowumian.removeEventListener(MouseEvent.CLICK,mianFn); tf=newTextField(); tf.width=300; if(score==5) { tf.text="恭喜你通關(guān)了"; } else { tf.text="很遺憾,請(qǐng)大俠重新來(lái)過(guò)"; } varformat:TextFormat=newTextFormat(); format.font="_sans"; format.color=0xFF0000; format.size=50; format.underline=true; tf.x=(stage.stageWidth-tf.width)/2; tf.y=(stage.stageHeight-tf.height)/2; tf.autoSize="center"; tf.defaultTextFormat=format; addChild(tf); myGameView.cuowumian.removeEventListener(MouseEvent.CLICK,mianFn); myEndBt=newButton(); addChild(myEndBt); myEndBt.label="Restart"; myEndBt.x=(stage.stageWidth-myEndBt.width)/2; myEndBt.y=300; myEndBt.addEventListener(MouseEvent.CLICK,restartFn);}functionrestartFn(e:MouseEvent){ myEndBt.removeEventListener(MouseEvent.CLICK,restartFn); removeChild(myEndBt); removeChild(tf); init();}實(shí)驗(yàn)結(jié)果注:可用貼圖的方式1、主要使用的知識(shí)點(diǎn)運(yùn)用Timer類(lèi)控制顯示對(duì)象的屬性來(lái)制作交互動(dòng)畫(huà)2、交互動(dòng)畫(huà)的效果(至少給出3個(gè),含制作過(guò)程及結(jié)果)實(shí)驗(yàn)總結(jié)注:包括制作過(guò)程中出現(xiàn)的問(wèn)題,實(shí)驗(yàn)心得體會(huì)及改進(jìn)意見(jiàn)等這算目前為止做的最完整的一個(gè)游戲了,很有挑戰(zhàn)性,我多添加了兩張圖片,成了有3個(gè)關(guān)卡的游戲,很有趣。上海建橋?qū)W院實(shí)驗(yàn)報(bào)告課程名稱(chēng):互動(dòng)媒體制作實(shí)驗(yàn)類(lèi)型:綜合型實(shí)驗(yàn)項(xiàng)目名稱(chēng):碰撞類(lèi)游戲制作實(shí)驗(yàn)地點(diǎn):多媒體機(jī)房實(shí)驗(yàn)日期:2013年6月6日實(shí)驗(yàn)?zāi)康暮鸵箪柟藺S3.0外部素材的導(dǎo)入、處理及控制方式;學(xué)會(huì)音頻的設(shè)置和使用;使用面向?qū)ο笏悸烽_(kāi)發(fā);Flash讀取XML數(shù)據(jù)素材連接技術(shù)及實(shí)現(xiàn)方法;制作滿(mǎn)足相應(yīng)指標(biāo)要求的交互媒體;實(shí)驗(yàn)內(nèi)容和原理確定內(nèi)容健康的主題作品素材的準(zhǔn)備制作作品的流程圖(分鏡頭腳本)遵循交互媒體的設(shè)計(jì)和制作流程,完成主題作品的制作主要儀器設(shè)備或環(huán)境PC機(jī);Flashcs5.5(或以上);Photoshopcs5(或以上);移動(dòng)終端5套;數(shù)碼照相機(jī)1臺(tái);數(shù)碼攝像機(jī)1臺(tái)。操作方法與實(shí)驗(yàn)步驟1、確定主題、設(shè)計(jì)流程圖、色彩搭配主題:12是男人成果30s原理:使用鍵盤(pán)上下左右控制白球移動(dòng),讓白球躲過(guò)藍(lán)球,碰到藍(lán)球游戲失敗。色彩搭配:鍵盤(pán)控制球白色;隨機(jī)自動(dòng)出來(lái)的球白色;背景黑色;道具:七彩色2、作品的素材處理(導(dǎo)入、拍攝、制作等方式)Goal元件元件1元件2所屬Goal類(lèi)所屬Q(mào)iu類(lèi)所屬Dao類(lèi)3、游戲主體部分功能拆分(撰寫(xiě))package{ importflash.display.MovieClip; importflash.events.*importflash.events.KeyboardEvent importflash.ui.Keyboard importflash.utils.Timer; publicclassGoalextendsMovieClip { varupPressed:Boolean=false; vardownPressed:Boolean=false; varleftPressed:Boolean=false; varrightPressed:Boolean=false; vartimer:Timer; publicfunctionGoal() { this.addEventListener(Event.ADDED_TO_STAGE,ADFn); } publicfunctionADFn(e:Event) { this.removeEventListener(Event.ADDED_TO_STAGE,ADFn); this.addEventListener(Event.ENTER_FRAME,fl_MoveInDirectionOfKey); stage.addEventListener(KeyboardEvent.KEY_DOWN,fl_SetKeyPressed); stage.addEventListener(KeyboardEvent.KEY_UP,fl_UnsetKeyPressed); } publicfunctionfl_MoveInDirectionOfKey(event:Event) { if(upPressed) { this.y-=5; } if(downPressed) { this.y+=5; } if(leftPressed) { this.x-=5; } if(rightPressed) { this.x+=5; } if(this.x>stage.stageWidth ||this.x<0 ||this.y>stage.stageHeight ||this.y<0){ clear() } } publicfunctionfl_SetKeyPressed(event:KeyboardEvent):void { switch(event.keyCode) { case38: { upPressed=true; break; }; caseKeyboard.DOWN: { downPressed=true; break; }; caseKeyboard.LEFT: { leftPressed=true; break; }; caseKeyboard.RIGHT: { rightPressed=true; break; } } }; publicfunctionfl_UnsetKeyPressed(event:KeyboardEvent):void { switch(event.keyCode) { caseKeyboard.UP: { upPressed=false; break; }; caseKeyboard.DOWN: { downPressed=false; break; }; caseKeyboard.LEFT: { leftPressed=false; break; }; caseKeyboard.RIGHT: { rightPressed=false; break; } } }publicfunctionclear(){ this.removeEventListener(Event.ENTER_FRAME,fl_MoveInDirectionOfKey); stage.removeEventListener(KeyboardEvent.KEY_DOWN,fl_SetKeyPressed); stage.removeEventListener(KeyboardEvent.KEY_UP,fl_UnsetKeyPressed); this.parent.removeChild(this) } publicfunctionchangeBig(){ this.scaleX*=1.5; this.scaleY*=1.5; timer=newTimer(1000,3); timer.addEventListener(TimerEvent.TIMER,timerFn); timer.start(); } publicfunctiontimerFn(e:TimerEvent){ changeSmall(); } publicfunctionchangeSmall(){ this.scaleX/=1.5; this.scaleY/=1.5; timer.stop(); timer.removeEventListener(TimerEvent.TIMER,timerFn); } } }4、關(guān)鍵的操作步驟(含主要代碼)及技巧鍵盤(pán)控制球的代碼:package{ importflash.display.MovieClip; importflash.events.*importflash.events.KeyboardEvent importflash.ui.Keyboard importflash.utils.Timer; publicclassGoalextendsMovieClip { varupPressed:Boolean=false; vardownPressed:Boolean=false; varleftPressed:Boolean=false; varrightPressed:Boolean=false; vartimer:Timer; publicfunctionGoal() { this.addEventListener(Event.ADDED_TO_STAGE,ADFn); } publicfunctionADFn(e:Event) { this.removeEventListener(Event.ADDED_TO_STAGE,ADFn); this.addEventListener(Event.ENTER_FRAME,fl_MoveInDirectionOfKey); stage.addEventListener(KeyboardEvent.KEY_DOWN,fl_SetKeyPressed); stage.addEventListener(KeyboardEvent.KEY_UP,fl_UnsetKeyPressed); } publicfunctionfl_MoveInDirectionOfKey(event:Event) { if(upPressed) { this.y-=5; } if(downPressed) { this.y+=5; } if(leftPressed) { this.x-=5; } if(rightPressed) { this.x+=5; } if(this.x>stage.stageWidth ||this.x<0 ||this.y>stage.stageHeight ||this.y<0){ clear() } } publicfunctionfl_SetKeyPressed(event:KeyboardEvent):void { switch(event.keyCode) { case38: { upPressed=true; break; }; caseKeyboard.DOWN: { downPressed=true; break; }; caseKeyboard.LEFT: { leftPressed=true; break; }; caseKeyboard.RIGHT: { rightPressed=true; break; } } }; publicfunctionfl_UnsetKeyPressed(event:KeyboardEvent):void { switch(event.keyCode) { caseKeyboard.UP: { upPressed=false; break; }; caseKeyboard.DOWN: { downPressed=false; break; }; caseKeyboard.LEFT: { leftPressed=false; break; }; caseKeyboard.RIGHT: { rightPressed=false; break; } } }publicfunctionclear(){ this.removeEventListener(Event.ENTER_FRAME,fl_MoveInDirectionOfKey); stage.removeEventListener(KeyboardEvent.KEY_DOWN,fl_SetKeyPressed); stage.removeEventListener(KeyboardEvent.KEY_UP,fl_UnsetKeyPressed); this.parent.removeChild(this) } publicfunctionchangeBig(){ this.scaleX*=1.5; this.scaleY*=1.5; timer=newTimer(1000,3); timer.addEventListener(TimerEvent.TIMER,timerFn); timer.start(); } publicfunctiontimerFn(e:TimerEvent){ changeSmall(); } publicfunctionchangeSmall(){ this.scaleX/=1.5; this.scaleY/=1.5; timer.stop(); timer.removeEventListener(TimerEvent.TIMER,timerFn); } } }隨機(jī)自動(dòng)出來(lái)的籃球代碼:package{ importflash.display.MovieClip; importflash.events.Event; publicclassQiuextendsMovieClip{ varQiuDirection:int=Math.floor(Math.random()*4) varxyDirection:int=0 varspeedX varspeedY vartemp:int=Math.floor(Math.random()*2) varnum:Number=1; publicfunctionQiu(){ this.addEventListener(Event.ADDED_TO_STAGE,ADFn) this.addEventListener(Event.ENTER_FRAME,timeFn) xyDirection=(temp==0)?1:-1 } publicfunctionADFn(e:Event){ this.removeEventListener(Event.ADDED_TO_STAGE,ADFn) switch(QiuDirection){ case0: this.x=Math.random()*stage.stageWidth this.y=0 this.speedX=Math.random()*4*xyDirection this.speedY=Math.random()*4 break case1: this.x=0 this.y=Math.random()*stage.stageHeight this.speedX=Math.random()*4 this.speedY=Math.random()*4*xyDirection break case2: this.x=Math.random()*stage.stageWidth this.y=stage.stageHeight this.speedX=Math.random()*4*xyDirection this.speedY=Math.random()*(-4) break case3: this.x=stage.stageWidth this.y=Math.random()*stage.stageHeight this.speedX=Math.random()*(-4) this.speedY=Math.random()*4*xyDirection break } } publicfunctiontimeFn(e:Event){ /*trace(this.parent["goal"])*/ if(this.hitTestObject(this.parent["goal"])){ myClearAll(); } else { this.x+=this.speedX*num this.y+=this.speedY*num if(this.x<0 ||this.x>stage.stageWidth ||this.y<0 ||this.y>stage.stageHeight){ clear() } } } publicfunctionmyClearAll(){ this.parent["clearALL"]() } publicfunctionclear(){ this.removeEventListener(Event.ENTER_FRAME,timeFn) this.parent.removeChild(this) } } }道具的代碼:package{ importflash.display.MovieClip; publicclassDaoextendsQiu{ publicfunctionDao(){ //constructorcode } //override表示重寫(xiě)父類(lèi)方法 overridepublicfunctionmyClearAll(){ this.parent["goal"].changeBig() clear();//繼承于Qiu,所以有clear() } } }實(shí)驗(yàn)結(jié)果注:可用貼圖的方式1、素材外部調(diào)用的實(shí)現(xiàn)2、游戲主體部分功能實(shí)現(xiàn)(給出關(guān)鍵部分功能代碼,含制作過(guò)程及結(jié)果)package{ importflash.display.MovieClip; importflash.events.*importflash.events.KeyboardEvent importflash.ui.Keyboard importflash.utils.Timer; publicclassGoalextendsMovieClip { varupPressed:Boolean=false; vardownPressed:Boolean=false; varleftPressed:Boolean=false; varrightPressed:Boolean=false; vartimer:Timer; publicfunctionGoal() { this.addEventListener(Event.ADDED_TO_STAGE,ADFn); } publicfunctionADFn(e:Event) { this.removeEventListener(Event.ADDED_TO_STAGE,ADFn); this.addEventListener(Event.ENTER_FRAME,fl_MoveInDirectionOfKey); stage.addEventListener(KeyboardEvent.KEY_DOWN,fl_SetKeyPressed); stage.addEventListener(KeyboardEvent.KEY_UP,fl_UnsetKeyPressed); } publicfunctionfl_MoveInDirectionOfKey(event:Event) { if(upPressed) { this.y-=5; } if(downPressed) { this.y+=5; } if(leftPressed) { this.x-=5; } if(rightPressed) { this.x+=5; } if(this.x>stage.stageWidth ||this.x<0 ||this.y>stage.stageHeight ||this.y<0){ clear() } } publicfunctionfl_SetKeyPressed(event:KeyboardEvent):void { switch(event.keyCode) { case38: { upPressed=true; break; }; caseKeyboard.DOWN: { downPressed=true; break; }; caseKeyboard.LEFT: { leftPressed=true; break; }; caseKeyboard.RIGHT: { rightPressed=true; break; } } }; publicfunctionfl_UnsetKeyPressed(event:KeyboardEvent):void { switch(event.keyCode) { caseKeyboard.UP: { upPressed=false; break; }; caseKeyboard.DOWN: { downPressed=false; break; }; caseKeyboard.LEFT: { leftPressed=false; break; }; caseKeyboard.RIGHT: { rightPressed=false; break; } } }publicfunctionclear(){ this.removeEventListener(Event.ENTER_FRAME,fl_MoveInDirectionOfKey); stage.removeEventListener(KeyboardEvent.KEY_DOWN,fl_SetKeyPressed); stage.removeEventListener(KeyboardEvent.KEY_UP,fl_UnsetKeyPressed); this.parent.removeChild(this) } publicfunctionchangeBig(){ this.scaleX*=1.5; this.scaleY*=1.5; timer=newTimer(1000,3); timer.addEventListener(TimerEvent.TIMER,timerFn); timer.start(); } publicfunctiontimerFn(e:TimerEvent){ changeSmall(); } publicfunctionchangeSmall(){ this.scaleX/=1.5; this.scaleY/=1.5; timer.stop(); timer.removeEventListener(TimerEvent.TIMER,timerFn); } } }4、關(guān)鍵的操作步驟(含主要代碼)及技巧鍵盤(pán)控制球的代碼:package{ importflash.display.MovieClip; importflash.events.*importflash.events.KeyboardEvent importflash.ui.Keyboard importflash.utils.Timer; publicclassGoalextendsMovieClip { varupPressed:Boolean=false; vardownPressed:Boolean=false; varleftPressed:Boolean=false; varrightPressed:Boolean=false; vartimer:Timer; publicfunctionGoal() { this.addEventListener(Event.ADDED_TO_STAGE,ADFn); } publicfunctionADFn(e:Event) { this.removeEventListener(Event.ADDED_TO_STAGE,ADFn); this.addEventListener(Event.ENTER_FRAME,fl_MoveInDirectionOfKey); stage.addEventListener(KeyboardEvent.KEY_DOWN,fl_SetKeyPressed); stage.addEventListener(KeyboardEvent.KEY_UP,fl_UnsetKeyPressed); } publicfunctionfl_MoveInDirectionOfKey(event:Event) { if(upPressed) { this.y-=5; } if(downPressed) { this.y+=5; } if(leftPressed) { this.x-=5; } if(rightPressed) { this.x+=5; } if(this.x>stage.stageWidth ||this.x<0 ||this.y>stage.stageHeight ||this.y<0){ clear() } } publicfunctionfl_SetKeyPressed(event:KeyboardEvent):void { switch(event.keyCode) { case38: { upPressed=true; break; }; caseKeyboard.DOWN: { downPressed=true; break; }; caseKeyboard.LEFT: { leftPressed=true; break; }; caseKeyboard.RIGHT: { rightPressed=true; break; } } }; publicfunctionfl_UnsetKeyPressed(event:KeyboardEvent):void { switch(event.keyCode) { caseKeyboard.UP: { upPressed=false; break; }; caseKeyboard.DOWN: { downPressed=false; break; }; caseKeyboard.LEFT: { leftPressed=false; break; }; caseKeyboard.RIGHT: { rightPressed=false; break; } } }publicfunctionclear(){ this.removeEventListener(Event.ENTER_FRAME,fl_MoveInDirectionOfKey); stage.removeEventListener(KeyboardEvent.KEY_DOWN,fl_SetKeyPressed); s

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論