Android开发教程:斗地主 [牌桌实现源码]


发一个Android斗地主游戏的牌桌实现。

为了节约内存资源,每张扑克牌都是剪切形成的,当然这也是当前编程的主流方法。

1、主Activity

  1. package com.bison;  
  2.   
  3. import android.app.Activity;  
  4. import android.content.pm.ActivityInfo;  
  5. import android.os.Bundle;  
  6. import android.view.Window;  
  7. import android.view.WindowManager;  
  8.   
  9. /** 
  10.  * 求某公司包养 
  11.  *  
  12.  * @author Bison 
  13.  *  
  14.  */  
  15. public class PukeActivity extends Activity {  
  16.     /** Called when the activity is first created. */  
  17.     @Override  
  18.     public void onCreate(Bundle savedInstanceState) {  
  19.         super.onCreate(savedInstanceState);  
  20.         // 这个事隐藏标题栏,不解释   
  21.         requestWindowFeature(Window.FEATURE_NO_TITLE);  
  22.         // 隐藏状态栏,你懂的   
  23.         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
  24.                 WindowManager.LayoutParams.FLAG_FULLSCREEN);  
  25.         /* 
  26.          * 开始有考虑使屏幕上扑克的排列随屏幕的分辨率变动 结果貌似不好做,注释掉了 Display display = 
  27.          * getWindowManager().getDefaultDisplay(); int screenWidth = 
  28.          * display.getWidth(); int screenHeight = display.getHeight(); 
  29.          */  
  30.   
  31.         // 使用代码锁定横屏   
  32.         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);  
  33.         // setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);这个是竖屏   
  34.         setContentView(new GameView(this));  
  35.     }  
  36. }
  • 1
  • 2
  • 3
  • 4
  • 下一页

相关内容