freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

畢業(yè)論文-基于android的飛機大戰(zhàn)游戲設計與實現(xiàn)(已改無錯字)

2023-02-16 22:01:39 本頁面
  

【正文】 @+id/pg_option_score android:title=@string/option_menu_score android:showAsAction=never/ item android:id=@+id/pg_option_start android:title=@string/option_menu_start android:showAsAction=never/ item android:id=@+id/pg_option_option android:title=@string/option_menu_option android:showAsAction=never/ /menu 洛陽師范學院 2022 屆本科生畢業(yè)設計 22 在游戲界面的 SkyGameScreenRollActivity 的方法 onCreateOptionsMenu(Menu menu)中注冊 文件,具體方法如下所示: public boolean onCreateOptionsMenu(Menu menu) { // TODO Autogenerated method stub MenuInflater inflater = new MenuInflater(this)。 (, menu)。 return true。 } 在游戲界面的 SkyGameScreenRollActivity 的方法 onOptionsItemSelected(MenuItem item)中為每個菜單選項編 寫響應事件,具體使用方法如下所示: public boolean onOptionsItemSelected(MenuItem item) { // TODO Autogenerated method stub Intent intent = null。 switch(()){ case : intent = new Intent()。 (EXIT)。 (intent)。 ()。 break。 case : intent = new Intent(,)。 (intent)。 break。 case : intent = new Intent(,)。 (intent)。 break。 case : intent = new Intent(,)。 (intent)。 break。 } return true。 } 發(fā)送短信 在用戶贏得一關的時候會發(fā)送一條信息“通過第 N 關”,實現(xiàn)該功能的代碼如下: private SmsManager sms = null。 = ()。 基于 Android 的飛機大戰(zhàn)游戲設計與開發(fā) 23 private String telNum = null。 telNum = 5554。//Android 虛擬機的 ID public void sendMessage(String telNum,String Message){ (telNum, null, Message, sentIntent , null)。 } (PS:Android 的發(fā)送短信存在一個 Bug 就是當前 DalvikVM 發(fā)送的短信它自己無法收到,如果同時開兩個 DalvikVM 其中一個發(fā)送短信的話,另一個會收到短信。 ) 鼠標控制玩家飛機移動 使用鼠標控制玩家飛機的移動,在自定義的 SurfaceView 的 onTouchEvent 方法中對于按下區(qū)域是否在玩家飛機圖片 所在位置做出判定,如果在,則在拖動的過程中不斷獲得鼠標的坐標,并將該坐標傳遞給玩家飛機,以此來使玩家飛機隨著鼠標的位置移動。具體根據(jù)鼠標移動控制玩家飛機移動的邏輯如下所示: public boolean onTouchEvent(MotionEvent event) { // TODO Autogenerated method stub int action = ()。 float x = ()。 float y = ()。 if(x = ()amp。amp。 x = ()+()amp。amp。 y = ()amp。amp。 y = ()+()){ if(action == ){ playerIsTouch = true。 } if(action == ){ playerIsTouch = false。 (x, y)。 } } if(action == ){ if(playerIsTouch){ ((),())。 } } return true。 } 洛陽師范學院 2022 屆本科生畢業(yè)設計 24 圖 410 鼠標控制玩家飛機序列圖 Activity 之間傳遞數(shù)據(jù) 使用到了 Activity 之間傳遞數(shù)據(jù)的技術(shù),將玩家當前獲得的分數(shù)傳遞給下一個 Activity以供使用。 : Intent intent = new Intent(,)。 (score, ())。 (intent)。 : Intent intent = getIntent()。 = (score, 1000)。 SurfaceView 中繪制文字 Android 的 Paint 對象在畫布上實時繪制玩家的分數(shù),代碼如下: public void drawScore(Canvas canvas){ Paint paint = new Paint()。 ()。 (20)。 (分數(shù) :+, viewWidth120, 30, paint)。 基于 Android 的飛機大戰(zhàn)游戲設計與開發(fā) 25 } 繪制文字的效果如圖 411 所示: 圖 411 繪制文字 碰撞邏輯 判斷飛機是否中彈的邏輯非常簡單就是在繪制飛機與子彈的時候判斷兩個圖片是否存在重合的部分,如果存在則在該重合位置繪制一個爆炸圖片,之后將中彈飛機從飛機隊列中刪除,子彈同樣的處理。 飛機中彈序列如圖 412 所示: 圖 412 飛機中彈序列圖 血條 繪制玩家飛機血線和 Boss 血線的邏輯是相同的,在統(tǒng)計飛機中彈次數(shù)的情況下使用圖洛陽師范學院 2022 屆本科生畢業(yè)設計 26 413 中的各個小圖對血線進行繪制。 圖 413 血線圖片集合 繪制血線的邏輯如圖 414 所示: 圖 414 繪制血線邏輯 具體負責繪制血線的函數(shù)( PS:該函數(shù)僅負責繪制,各種邏輯判斷的事情它不做)如下: public void drawPlayerBloodLine(Canvas canvas){ int num = playerIsShortedCount/5。 int leng = ()()*num。 Bitmap blood = null。 Bitmap empty = null。 if(num == 0){ ( fullBlood, 0, viewHeight (), null)。 }else if(leng ()){ blood = ( fullBlood, 0, 0, leng, ())。 empty = ( emptyBlood, leng, 0, ()leng, ())。 ( blood, 0, viewHeight (), null)。 ( empty, 基于 Android 的飛機大戰(zhàn)游戲設計與開發(fā) 27 (), viewHeight (), null)。 }else if(leng 0){ blood = bloodBegin。 empty = ( emptyBlood, (), 0, ()(), ())。 ( blood, 0, viewHeight (), null)。 ( empty, (), viewHeight (), null)。 }else{ ( emptyBlood, 0, viewHeight (), null)。 isPlayerDead = true。 } } 設置界面 當前界面使用的是普通的 layout,生成的設置界面如圖 415 所示: 圖 415 設置界面 洛陽師范學院 2022 屆本科生畢業(yè)設計 28 ?xml version= encoding=utf8? LinearLayout xmlns:android= android:layout_width=match_parent android:layout_height=match_parent android:orientation=vertical LinearLayout android:layout_width=match_parent android:layout_height=wrap_content TextView android:id=@+id/tv_option_sound android:layout_width=0dp android:layout_height=wrap_content android:layout_weight=1 android:gravity=center android:text=@string/tv_option_sound android:textSize=20dp / SeekBar android:id=@+id/option_sound_seekBar android:layout_width=0dp android:layout_height=wrap_content android:layout_weight=4 / /LinearLayout RadioGroup android:id=@+id/option_grade_radio_group android:layout_width=wrap_content android:layout_height=wrap_content RadioButton android:id=@+id/option_grade_simple android:layout_width=wrap_content android:layout_height=wrap_content android:checked=true android:text=@string/option_radioButton_simple / RadioButton android:id=@+id/option_grade_middle android:layout_width=wrap_content android:layout_height=wrap_content android:text=@string/option_radioButton_middle / RadioButton android:id=@+id/option_grade_difficult android:layout_width=wrap_content android:layout_height=wrap_content android:text=@string/option_radioButton_difficult / /RadioGroup 基于 Android 的飛機大戰(zhàn)游戲設計與開發(fā) 29 LinearLayout android:layout_width=match_parent android:l
點擊復制文檔內(nèi)容
公司管理相關推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1