[Java] xiaoyouxi →→→→→进入此内容的聊天室

来自 , 2021-05-02, 写在 Java, 查看 317 次.
URL http://www.code666.cn/view/0245952e
  1. package com.chuguangming.KickFlybug.View;
  2.   import com.chuguangming.GameModeActivity;
  3.   import com.chuguangming.KickFly;
  4.   import com.chuguangming.R;
  5.   import com.chuguangming.KickFlybug.Config.GameMainConfig;
  6.   import com.chuguangming.KickFlybug.Until.ActivityUtil;
  7.   import com.chuguangming.KickFlybug.Until.AudioUtil;
  8.   import com.chuguangming.KickFlybug.Until.GameObjData;
  9.   import android.content.Context;
  10.   import android.content.Intent;
  11.   import android.graphics.Canvas;
  12.   import android.graphics.Color;
  13.   import android.graphics.Paint;
  14.   import android.graphics.Rect;
  15.   import android.graphics.Typeface;
  16.   import android.view.MotionEvent;
  17.   import android.view.View;
  18.   public class GameMainView extends View
  19.   {
  20.   // 上下文
  21.   private Context myContext;
  22.   // 定义开始与设置按钮
  23.   private Rect StartRect = new Rect(275, 265, 543, 301);
  24.   private Rect SetRect = new Rect(274, 330, 549, 374);
  25.   private Rect AboutRect = new Rect(272, 412, 559, 467);
  26.   //定义小分别率的按钮区域
  27.   private Rect StartRectS=new Rect(148,160,312,195);
  28.   private Rect SetRectS=new Rect(146,219,308,255);
  29.   public GameMainView(Context context)
  30.   {
  31.   super(context);
  32.   myContext = context;
  33.   // 开始背景声音线程线程
  34.   Thread MusicThread = new Thread(new MusicHandler());
  35.   MusicThread.start();
  36.   }
  37.   @Override
  38.   protected void onDraw(Canvas canvas)
  39.   {
  40.   super.onDraw(canvas);
  41.   // 1为输出调试信息
  42.   int debug = 2;
  43.   switch (debug)
  44.   {
  45.   case 1:
  46.   Paint myPaint = new Paint();
  47.   String familyName = "宋体";
  48.   Typeface font = Typeface.create(familyName, Typeface.BOLD);
  49.   myPaint.setAntiAlias(true);
  50.   myPaint.setColor(Color.RED);
  51.   myPaint.setTypeface(font);
  52.   myPaint.setTextSize(22);
  53.   canvas.drawText(ActivityUtil.SCREEN_WIDTH + "*"
  54.   + ActivityUtil.SCREEN_HEIGHT, 100, 100, myPaint);
  55.   break;
  56.   case 2:
  57.   // 绘制背景
  58.   canvas.drawBitmap(ActivityUtil.returnPic("bg3", myContext), null,
  59.   GameMainConfig.returnDescBackgroundRect(), new Paint());
  60.   break;
  61.   }
  62.   }
  63.   @Override
  64.   public boolean onTouchEvent(MotionEvent event)
  65.   {
  66.   if (event.getAction() == MotionEvent.ACTION_DOWN)
  67.   {
  68.   int ax = (int) event.getX();
  69.   int ay = (int) event.getY();
  70.   // ActivityUtil.ShowXYMessage(getContext(), ax, ay);
  71.   // 判断是否是低分屏的机器如G3
  72.   if (ActivityUtil.SCREEN_WIDTH == 480)
  73.   {
  74.   //ActivityUtil.ShowXYMessage(getContext(), ax, ay);
  75.   // 点击到开始按钮
  76.   if (StartRectS.contains(ax, ay))
  77.   {
  78.   // 开始按钮声音线程线程
  79.   Thread ButtonMusicThread = new Thread(
  80.   new ButtonMusicHandler());
  81.   ButtonMusicThread.start();
  82.   // ActivityUtil.PlaySoundPool(myContext, R.raw.music3);
  83.   // 停顿二秒再进入系统
  84.   ActivityUtil.SleepTime(1000);
  85.   // ActivityUtil.ShowXYMessage(getContext(), ax, ay);
  86.   // 转向到继续游戏
  87.   Intent intent = new Intent();
  88.   intent.setClass(getContext(), KickFly.class);
  89.   // 设定游戏的模式为打死一百虫子就结束
  90.   GameObjData.CURRENT_GAME_MODE = GameObjData.MODE_100C;
  91.   // 转向登陆后的页面
  92.   getContext().startActivity(intent);
  93.   }
  94.   // 点击到设置按钮
  95.   if (SetRectS.contains(ax, ay))
  96.   {
  97.   // 开始按钮声音线程线程
  98.   Thread ButtonMusicThread = new Thread(
  99.   new ButtonMusicHandler());
  100.   ButtonMusicThread.start();
  101.   ActivityUtil.SleepTime(1000);
  102.   // 转向到继续游戏
  103.   Intent intent = new Intent();
  104.   intent.setClass(getContext(), GameModeActivity.class);
  105.   // 转向登陆后的页面
  106.   getContext().startActivity(intent);
  107.   // ActivityUtil.ShowXYMessage(getContext(), ax, ay);
  108.   }
  109.   } else
  110.   {
  111.   // 点击到开始按钮
  112.   if (StartRect.contains(ax, ay))
  113.   {
  114.   // 开始按钮声音线程线程
  115.   Thread ButtonMusicThread = new Thread(
  116.   new ButtonMusicHandler());
  117.   ButtonMusicThread.start();
  118.   // ActivityUtil.PlaySoundPool(myContext, R.raw.music3);
  119.   // 停顿二秒再进入系统
  120.   ActivityUtil.SleepTime(1000);
  121.   // ActivityUtil.ShowXYMessage(getContext(), ax, ay);
  122.   // 转向到继续游戏
  123.   Intent intent = new Intent();
  124.   intent.setClass(getContext(), KickFly.class);
  125.   // 设定游戏的模式为打死一百虫子就结束
  126.   GameObjData.CURRENT_GAME_MODE = GameObjData.MODE_100C;
  127.   // 转向登陆后的页面
  128.   getContext().startActivity(intent);
  129.   }
  130.   // 点击到设置按钮
  131.   if (SetRect.contains(ax, ay))
  132.   {
  133.   // 开始按钮声音线程线程
  134.   Thread ButtonMusicThread = new Thread(
  135.   new ButtonMusicHandler());
  136.   ButtonMusicThread.start();
  137.   ActivityUtil.SleepTime(1000);
  138.   // 转向到继续游戏
  139.   Intent intent = new Intent();
  140.   intent.setClass(getContext(), GameModeActivity.class);
  141.   // 转向登陆后的页面
  142.   getContext().startActivity(intent);
  143.   // ActivityUtil.ShowXYMessage(getContext(), ax, ay);
  144.   }
  145.   // 点击到关于按钮
  146.   if (AboutRect.contains(ax, ay))
  147.   {
  148.   }
  149.   }
  150.   postInvalidate();// 刷新屏幕
  151.   }
  152.   return super.onTouchEvent(event);
  153.   }
  154.   class MusicHandler implements Runnable
  155.   {
  156.   public void run()
  157.   {
  158.   try
  159.   {
  160.   Thread.sleep(4000);
  161.   } catch (InterruptedException e)
  162.   {
  163.   e.printStackTrace();
  164.   }
  165.   // 播放声音
  166.   AudioUtil.PlayMusicLoop(myContext, R.raw.backsound);
  167.   }
  168.   }
  169.   class ButtonMusicHandler implements Runnable
  170.   {
  171.   public void run()
  172.   {
  173.   // 播放声音
  174.   AudioUtil.PlayMusicLoop(myContext, R.raw.musicbutton);
  175.   }
  176.   }
  177.   }

回复 "xiaoyouxi"

这儿你可以回复上面这条便签

captcha