歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android開發教程:斗地主 [牌桌實現源碼]

Android開發教程:斗地主 [牌桌實現源碼]

日期:2017/3/1 10:25:04   编辑:Linux編程

發一個Android斗地主游戲的牌桌實現。

為了節約內存資源,每張撲克牌都是剪切形成的,當然這也是當前編程的主流方法。

1、主Activity

  1. package com.bison;
  2. import android.app.Activity;
  3. import android.content.pm.ActivityInfo;
  4. import android.os.Bundle;
  5. import android.view.Window;
  6. import android.view.WindowManager;
  7. /**
  8. * 求某公司包養
  9. *
  10. * @author Bison
  11. *
  12. */
  13. public class PukeActivity extends Activity {
  14. /** Called when the activity is first created. */
  15. @Override
  16. public void onCreate(Bundle savedInstanceState) {
  17. super.onCreate(savedInstanceState);
  18. // 這個事隱藏標題欄,不解釋
  19. requestWindowFeature(Window.FEATURE_NO_TITLE);
  20. // 隱藏狀態欄,你懂的
  21. getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  22. WindowManager.LayoutParams.FLAG_FULLSCREEN);
  23. /*
  24. * 開始有考慮使屏幕上撲克的排列隨屏幕的分辨率變動 結果貌似不好做,注釋掉了 Display display =
  25. * getWindowManager().getDefaultDisplay(); int screenWidth =
  26. * display.getWidth(); int screenHeight = display.getHeight();
  27. */
  28. // 使用代碼鎖定橫屏
  29. setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
  30. // setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);這個是豎屏
  31. setContentView(new GameView(this));
  32. }
  33. }
Copyright © Linux教程網 All Rights Reserved