版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
77/79上海建橋?qū)W院本科實驗報告課程名稱:互動媒體制作學(xué)號:姓名:專業(yè):數(shù)字媒體藝術(shù)班級:指導(dǎo)教師:課內(nèi)實驗?zāi)夸浖俺煽冃蛱枌嶒灻Q頁碼成績1交互事件動畫(星星亮滿天)12文字回合類游戲制作43找茬類小游戲74碰撞類游戲制作11信息技術(shù)學(xué)院2012年12月1日上海建橋?qū)W院實驗報告課程名稱:互動媒體制作實驗類型:驗證型實驗項目名稱:交互事件動畫(星星亮滿天)實驗地點:多媒體機房實驗日期:2013年3月7日實驗?zāi)康暮鸵笫煜さ倪\用;鞏固AS3.0的程序結(jié)構(gòu)和基本語法;能夠創(chuàng)建和調(diào)用系統(tǒng)函數(shù);能夠熟練運用程序基本結(jié)構(gòu);制作滿足相應(yīng)指標(biāo)要求的正確運行的小游戲;實驗內(nèi)容和原理使用顯示對象、對象點擊事件、三大元件等編寫交互功能程序的基本結(jié)構(gòu)包括:順序結(jié)構(gòu)、選擇結(jié)構(gòu)、循環(huán)結(jié)構(gòu)事件函數(shù):MouseEvent事件類時間函數(shù):Timer類主要儀器設(shè)備或環(huán)境PC機;Flashcs5.5(或以上);Photoshopcs5(或以上);移動終端5套。操作方法與實驗步驟1、確定游戲的主題(名稱、色彩配置、主題思想、使用方法等)名稱:星星亮滿天色彩配置:深邃的天空+顏色隨機的星星主題思想:在背景天空區(qū)域,左鍵單擊星星出現(xiàn),并且顏色隨機使用方法:鼠標(biāo)左鍵單擊2、確定游戲的設(shè)計流程圖3、游戲素材的采集、導(dǎo)入或制作導(dǎo)入圖片bg,并轉(zhuǎn)成元件導(dǎo)入圖片星光,并制作成動畫4、關(guān)鍵的操作步驟(含主要代碼)及技巧星光轉(zhuǎn)換成元件,并制作動畫,達(dá)到星星從大到小,從小到大的變化。然后將此元件再次轉(zhuǎn)換,并再次制作動畫,共5幀,每幀星星顏色不一樣。在bg上的天空上制作一個遮罩層mc,并對mc添加一個鼠標(biāo)監(jiān)聽。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)");}實驗結(jié)果注:可用貼圖的方式1、主要使用的AS3.0的知識點添加鼠標(biāo)監(jiān)聽、實例對象顯示在鼠標(biāo)點擊的位置(mystar.x=mouseX;mystar.y=mouseY;)、數(shù)學(xué)函數(shù)(隨機數(shù)、向下取整)、gotoAndStop2、小游戲的效果(至少給出3個,含制作過程及結(jié)果)實驗總結(jié)注:包括制作過程中出現(xiàn)的問題,實驗心得體會及改進(jìn)意見等在老師的帶領(lǐng)下完成了此次小游戲,初次體驗到Flash的神奇,特別是隨機數(shù)的出現(xiàn)。在這種濃烈的興趣下,我將更認(rèn)真的學(xué)習(xí)Flash。上海建橋?qū)W院實驗報告課程名稱:互動媒體制作實驗類型:設(shè)計型實驗項目名稱:文字回合類游戲制作(面向過程及時間函數(shù))實驗地點:多媒體機房實驗日期:2013年3月21日實驗?zāi)康暮鸵箪柟堂嫦驅(qū)ο缶幊痰南嚓P(guān)概念;構(gòu)造函數(shù)的創(chuàng)建和使用;事件處理機制及Event類的創(chuàng)建、使用(事件偵聽器);能夠熟練運用鼠標(biāo)事件;制作滿足要求的動畫效果;實驗內(nèi)容和原理使用事件驅(qū)動編寫AS3.0應(yīng)用程序(物體移動等的動畫效果)鼠標(biāo)事件:CLICK、MOUSE_MOVE、MOUSE_OVER、MOUSE_OUT、MOUSE_WHEEL等鍵盤事件:KeyboardEvent.KEY_DOWN(UP)等時間函數(shù):TimerEvent.TIMER、TimerEvent.TIMER_COMPLETE主要儀器設(shè)備或環(huán)境PC機;Flashcs5.5(或以上);Photoshopcs5(或以上);移動終端5套。操作方法與實驗步驟1、確定作品的主題(名稱、色彩配置、主題思想、使用方法等)名稱:勇者斗惡龍主題思想:為了描寫戰(zhàn)斗,對勇者與惡龍設(shè)置特性,如名字,攻擊力,防御力以及速度,運行游戲,出現(xiàn)打斗文字。使用方法:結(jié)果顯示在輸入框里2、主題作品的設(shè)計運行游戲后,勇者與惡龍輪流發(fā)動攻擊,最后得出勝負(fù)。3、素材的導(dǎo)入或制作沒有素材的導(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="毀滅光線";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ā)動了"+attacker["skill"+skillIndex]+","++"損失了"+damage+"點HP!"); if(defender.HP<=0){ trace(+"終于支持不住,倒下了!\n"++"取得了勝利!"); timer.removeEventListener(TimerEvent.TIMER,round); trace("\nGameOver"); return; } trace(+"HP:"+hero.HP+"\t"++"HP:"+monster.HP);}實驗結(jié)果注:可用貼圖的方式1、主要使用的知識點使用事件驅(qū)動編寫AS3.0應(yīng)用程序(物體移動等的動畫效果)鼠標(biāo)事件:CLICK、MOUSE_MOVE、MOUSE_OVER、MOUSE_OUT、MOUSE_WHEEL等鍵盤事件:KeyboardEvent.KEY_DOWN(UP)等時間函數(shù):TimerEvent.TIMER、TimerEvent.TIMER_COMPLETE2、作品的效果圖(至少給出3個,含制作過程及結(jié)果)實驗總結(jié)注:包括制作過程中出現(xiàn)的問題,實驗心得體會及改進(jìn)意見等大體上了解到我們平常玩的回合游戲的制作過程,很有趣,我很喜歡這個。不過我想要是加上圖片和效果的話,難度會提升很多。上海建橋?qū)W院實驗報告課程名稱:互動媒體制作實驗類型:設(shè)計型實驗項目名稱:找茬類事件點擊類小游戲?qū)嶒灥攸c:多媒體機房實驗日期:2013年4月15日實驗?zāi)康暮鸵箪柟藺S3.0中核心類及顯示對象的相關(guān)概念;學(xué)會MovieClip類、Sprite類的創(chuàng)建及使用;學(xué)會AS3.0中創(chuàng)建動畫的幾種方式;能夠熟練運用顯示對象的屬性;能夠熟練運用timer類創(chuàng)建動畫(效果);制作滿足相應(yīng)要求的交互動畫;實驗內(nèi)容和原理確定內(nèi)容健康的主題相關(guān)素材的準(zhǔn)備制作交互動畫的流程圖(分鏡頭腳本)運用Timer類控制顯示對象的屬性來制作交互動畫主要儀器設(shè)備或環(huán)境PC機;Flashcs5(或以上);Photoshopcs5(或以上);移動終端5套;數(shù)碼照相機1臺;數(shù)碼攝像機1臺;數(shù)位板1個。操作方法與實驗步驟1、確定主題、設(shè)計流程圖主題:找茬游戲設(shè)計流程圖:2、游戲整體流程拆分游戲開始初始化:開始按鈕定義、開始界面的設(shè)置、初始化數(shù)值游戲主題部分:添加三個文本框,一個計分?jǐn)?shù),一個倒計時,一個統(tǒng)計剩余幾個錯找到幾個錯。添加Timer時間監(jiān)聽,用來倒計時。對cuowumian、cuo1、cuo2、cuo3.、cuo4.、cuo5添加鼠標(biāo)事件監(jiān)聽,MouseEvent.CLICK。游戲結(jié)束部分:移除游戲主體頁面上所有東西,移除監(jiān)聽。根據(jù)找出的錯的個數(shù)判斷是否通關(guān),并顯示在名為tf的文本框里。添加一個Restart按鈕,實現(xiàn)重玩的功能。3、三大游戲流程部分功能實現(xiàn)游戲開始初始化、開始界面的設(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="很遺憾,請大俠重新來過"; } 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();//游戲開始初始化functioninit(){ //開始按鈕定義 myStartBt=newButton(); addChild(myStartBt); myStartBt.x=(stage.stageWidth-myStartBt.width)/2; myStartBt.y=300; myStartBt.label="Start"; myStartBt.addEventListener(MouseEvent.CLICK,myStartBtFn); //開始界面的設(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)+"錯,剩余"+String(allScore-score)+"處錯"; 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="很遺憾,請大俠重新來過"; } 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();}實驗結(jié)果注:可用貼圖的方式1、主要使用的知識點運用Timer類控制顯示對象的屬性來制作交互動畫2、交互動畫的效果(至少給出3個,含制作過程及結(jié)果)實驗總結(jié)注:包括制作過程中出現(xiàn)的問題,實驗心得體會及改進(jìn)意見等這算目前為止做的最完整的一個游戲了,很有挑戰(zhàn)性,我多添加了兩張圖片,成了有3個關(guān)卡的游戲,很有趣。上海建橋?qū)W院實驗報告課程名稱:互動媒體制作實驗類型:綜合型實驗項目名稱:碰撞類游戲制作實驗地點:多媒體機房實驗日期:2013年6月6日實驗?zāi)康暮鸵箪柟藺S3.0外部素材的導(dǎo)入、處理及控制方式;學(xué)會音頻的設(shè)置和使用;使用面向?qū)ο笏悸烽_發(fā);Flash讀取XML數(shù)據(jù)素材連接技術(shù)及實現(xiàn)方法;制作滿足相應(yīng)指標(biāo)要求的交互媒體;實驗內(nèi)容和原理確定內(nèi)容健康的主題作品素材的準(zhǔn)備制作作品的流程圖(分鏡頭腳本)遵循交互媒體的設(shè)計和制作流程,完成主題作品的制作主要儀器設(shè)備或環(huán)境PC機;Flashcs5.5(或以上);Photoshopcs5(或以上);移動終端5套;數(shù)碼照相機1臺;數(shù)碼攝像機1臺。操作方法與實驗步驟1、確定主題、設(shè)計流程圖、色彩搭配主題:12是男人成果30s原理:使用鍵盤上下左右控制白球移動,讓白球躲過藍(lán)球,碰到藍(lán)球游戲失敗。色彩搭配:鍵盤控制球白色;隨機自動出來的球白色;背景黑色;道具:七彩色2、作品的素材處理(導(dǎo)入、拍攝、制作等方式)Goal元件元件1元件2所屬Goal類所屬Q(mào)iu類所屬Dao類3、游戲主體部分功能拆分(撰寫)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)鍵的操作步驟(含主要代碼)及技巧鍵盤控制球的代碼: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); } } }隨機自動出來的籃球代碼: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表示重寫父類方法 overridepublicfunctionmyClearAll(){ this.parent["goal"].changeBig() clear();//繼承于Qiu,所以有clear() } } }實驗結(jié)果注:可用貼圖的方式1、素材外部調(diào)用的實現(xiàn)2、游戲主體部分功能實現(xiàn)(給出關(guān)鍵部分功能代碼,含制作過程及結(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)鍵的操作步驟(含主要代碼)及技巧鍵盤控制球的代碼: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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030年中國兒童床數(shù)據(jù)監(jiān)測研究報告
- 二零二五年度智能家電配件采購協(xié)議4篇
- 二手房代理委托協(xié)議(2024版)
- 2025年度教師教育咨詢服務(wù)聘用協(xié)議3篇
- 二零二五年度電梯門套安裝與應(yīng)急救援預(yù)案合同3篇
- 2025至2031年中國食用油包裝行業(yè)投資前景及策略咨詢研究報告
- 2025至2031年中國警用警戒帶行業(yè)投資前景及策略咨詢研究報告
- 2025年度高端商務(wù)車輛租賃服務(wù)合同范本23篇
- 功能性食品研發(fā)趨勢-深度研究
- 2025至2030年中國聚氨酯發(fā)泡保溫材料數(shù)據(jù)監(jiān)測研究報告
- 2025年度私立學(xué)校教師聘用合同(初中部專業(yè)學(xué)科)3篇
- DB32T 4880-2024民用建筑碳排放計算標(biāo)準(zhǔn)
- 銀行2025年紀(jì)檢工作計劃
- 注射泵管理規(guī)范及工作原理
- 國潮風(fēng)中國風(fēng)2025蛇年大吉蛇年模板
- 故障診斷技術(shù)的國內(nèi)外發(fā)展現(xiàn)狀
- 2024年發(fā)電廠交接班管理制度(二篇)
- 《數(shù)學(xué)課程標(biāo)準(zhǔn)》義務(wù)教育2022年修訂版(原版)
- 農(nóng)機維修市場前景分析
- 實驗室的設(shè)計規(guī)劃
評論
0/150
提交評論