登录
首页 » Android » 物联网开关控制程序

物联网开关控制程序

于 2022-02-02 发布 文件大小:1.93 MB
0 66
下载积分: 2 下载次数: 1

代码说明:

DIFI物联,一款简易的物联网开发源代码,适合初学者进行学习和使用

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • android 短信拦截 实例完整源码下载
    可实现拦截短信,自动转发的功能。 部分代码:import android.app.AlarmManager;import android.app.PendingIntent;import android.app.Service;import android.content.Context;import android.content.Intent;import android.content.IntentFilter;import android.os.IBinder;import android.os.PowerManager;import android.os.PowerManager.WakeLock;public class MyService extends Service{ SMSReceiver rs=null; static MyService service; private static PendingIntent pi = null; public static AlarmManager am = null; @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); service=this; pm = (PowerManager) getSystemService(Context.POWER_SERVICE); registerAlarm(); acquireWakeLock(this); registerRecever(); } @Override public void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); releaseWakeLock(); unregisterAlarm(); } private void registerRecever(){ rs=new SMSReceiver(); IntentFilter filter=new IntentFilter(); filter.addAction("android.provider.Telephony.SMS_RECEIVED"); filter.setPriority(1000); registerReceiver(rs, filter); } @Override public int onStartCommand(Intent intent, int flags, int startId) { // TODO Auto-generated method stub if(rs==null)registerRecever(); return START_STICKY; } public static WakeLock wakeLock = null; private static PowerManager pm = null; public static synchronized void acquireWakeLock(Context c) { if (null == wakeLock) { wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "smslock"); wakeLock.acquire(); } } public static synchronized void releaseWakeLock() { if (wakeLock == null) return; if (wakeLock.isHeld()) { wakeLock.release(); wakeLock = null; } } /** * 启动重复型定时器 */ public static void registerAlarm() { if(Config.getAlarm())return; Intent intent = new Intent(service, AlarmReceiver.class); pi = PendingIntent.getBroadcast(service, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); // 设置一个PendingIntent对象,发送广播 am = (AlarmManager) service.getSystemService(Context.ALARM_SERVICE); // 获取AlarmManager对象, Config.setAlarm(true); am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 30*60*1000, pi); } /** * 取消定时器 */ public static void unregisterAlarm() { am.cancel(pi); am = null; Config.setAlarm(false); }}
    2014-05-21下载
    积分:1
  • android 各种常用对话框(dialog) 实例源码下载
    android 各种常用对话框(dialog) 实例源码下载
    2015-02-03下载
    积分:1
  • android 视频对讲 例子源码下载
    Android版视频会议是Web版视频会议系统的移动版,它构建在Android手机上,主要提供Web版视频会议系统中的一系列的提醒功能,如站内短信、视频会议提醒以及待办事宜等。
    2015-04-12下载
    积分:1
  • 蓝牙调试软件
    用于调试BLE蓝牙模块的android APP,只适用于BLE蓝牙4.0以上,android 4.3系统以上的手机
    2022-02-04 13:08:00下载
    积分:1
  • Android
    2022-08-06 05:50:46下载
    积分:1
  • android 的 webSocket
    消息Web Socket客户端
    2022-08-09 08:22:13下载
    积分:1
  • android 打飞机游戏 源码下载
    import com.pic.SpriteCmd.MainState;import android.app.Activity;import android.content.Context;import android.graphics.Bitmap;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.Rect;import android.graphics.drawable.BitmapDrawable;import android.hardware.Sensor;import android.hardware.SensorEvent;import android.hardware.SensorEventListener;import android.hardware.SensorManager;import android.media.MediaPlayer;import android.os.Bundle;import android.view.MotionEvent;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;public class PictureView extends View implements Runnable,SensorEventListener{private Context context;private  int scrWidth;//屏幕的宽度private  int scrHeight;//屏幕的高度private  int MainTime = 0; //主计时器private  Bitmap imgBackground = null;//背景图片private  Bitmap imgBackground2 = null;private ButtonUtil ButtonStart = null;//开始按钮private ButtonUtil ButtonHelp = null;//帮助按钮private ButtonUtil ButtonScore = null;private ButtonUtil ButtonDetail = null;private  Bitmap imgStart = null;//开始按钮对应的图片private  Bitmap imgHelp = null;//帮助按钮对应的图片private  Bitmap imgScore = null;private  Bitmap imgDetail = null;private ButtonUtil ButtonFirst = null;//选关界面第一关对应按钮private ButtonUtil ButtonSecond = null;//选关界面第二关对应按钮private Bitmap imgFirst = null;//第一关对应图片private Bitmap imgSecond = null;//第二关对应图片private Bitmap imgHelpDisplay = null;//帮助图片private Bitmap imgScoreDisplay = null;//高分图片private Bitmap imgDetailDisplay = null;private ButtonUtil ButtonReturn = null;//返回按钮private Bitmap imgReturn = null;//返回按钮对应图片private ButtonUtil ButtonSound = null;//声音开关按钮private Bitmap imgSoundOn = null;//开声音对应图片private Bitmap imgSoundOff = null;//关声音对应图片private Boolean is_SoundOn = true;//声音是否开private Boolean is_LeverUp = false;//是否过关private int DeadEnemyCnt = 0;//敌人死亡计数器     当死亡敌人个数达到某个数时   过关private int LeverCnt = 0;//过关界面的计数器private static MediaPlayer mediaPlayer = null;//声音播放对象public enum GameState//游戏状态{GAMESTATE_MENU, //菜单GAMESTATE_LEVELGUIDE, //关数提示,显示第一关,第二关 。。GAMESTATE_HELP, GAMESTATE_SCORE,GAMESTATE_DETAIL,GAMESTATE_GAME, //游戏}public  GameState GameState; // 游戏状态public static final int STAR_NUM = 30;public SpriteCmd rgSpriteCmd = new SpriteCmd();////主角SpriteCmd类对象实例化public SpriteCmd rgCmdStar[] = new SpriteCmd[30];//星星对象public SpriteCmd rgBulletCmd[] = new SpriteCmd[20];//主角子弹对象public SpriteCmd rgEnemy1Cmd = new SpriteCmd();//敌人1的SpriteCmd类对象public SpriteCmd rgEnemy2Cmd = new SpriteCmd();//敌人2对象public SpriteCmd rgEnemy3Cmd = new SpriteCmd();//敌人3对象public SpriteCmd rgEnemy4Cmd = new SpriteCmd();public SpriteCmd rgEnemy5Cmd = new SpriteCmd();public SpriteCmd rgBombCmds[] = new SpriteCmd[5];//敌人死亡时候爆炸的对象private int LeverNum;//关数计数器public Bitmap imgPlane;//主角飞机对应图片public Bitmap imgStar;//星星对应图片public Bitmap imgBullet;//子弹图片public Bitmap imgEnemy1;//敌人1对应图片public Bitmap imgEnemy2;//敌人2对象图片public Bitmap imgEnemy3;public Bitmap imgEnemy4;public Bitmap imgEnemy5;public Bitmap imgBomb; //炸弹对应图片public Bitmap imgPassLerver;//过关图片public SpriteCmd rgGameover = new SpriteCmd();public Bitmap imgBloodBg;//血量框图片public Bitmap imgBlood;//血量图片public boolean IsRightKeyRealess = true;//右键是否释放public boolean IsLeftKeyRealess = true;//左键是否释放public boolean IsUpKeyRealess = true;//上键是否释放public boolean IsDownKeyRealess = true;//下键是否释放private SensorManager sm;//传感器管理器private Sensor sensor;//重力传感器对象public float x_sensor = 0;//重力传感器x方向的位置偏移public float y_sensor = 0;//重力传感器y方向的位置偏移public float z_sensor = 0;//重力传感器z方向的位置偏移public SpriteCmd rgBackground1 = new SpriteCmd();//背景对象1public SpriteCmd rgBackground2 = new SpriteCmd();//背景对象2public SpriteCmd rgLerver = new SpriteCmd();//“恭喜过关”对象public SpriteCmd rgBloodBg = new SpriteCmd();//“血量框”对象public SpriteCmd rgBlood = new SpriteCmd();//“血量”对象public boolean  Is_exit = false;//是否退出游戏public PictureView(Context context){      super(context);//调用父类的构造方法      MainTime = 0; // 主计时清零      sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);  sensor = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);// 得到一个重力传感器实例  sm.registerListener(this, sensor, SensorManager.SENSOR_DELAY_GAME);      new Thread(this).start(); //启动线程    通过start()方法找到run()方法      this.context = context;      Is_exit = false;      }public void TurnToMenu()//进入菜单{imgBackground =((BitmapDrawable)getResources().getDrawable(R.drawable.bg1)).getBitmap();//背景图片if (imgStart == null){imgStart = ((BitmapDrawable)getResources().getDrawable(R.drawable.start)).getBitmap();//“开始游戏”的图片}if (imgHelp == null){imgHelp = ((BitmapDrawable)getResources().getDrawable(R.drawable.help)).getBitmap();//“游戏帮助”的图片}if (imgScore == null){imgScore = ((BitmapDrawable)getResources().getDrawable(R.drawable.score)).getBitmap();//“高分”的图}if (imgDetail == null){imgDetail = ((BitmapDrawable)getResources().getDrawable(R.drawable.detail)).getBitmap();//“信息”的图}if (imgReturn == null){imgReturn = ((BitmapDrawable)getResources().getDrawable(R.drawable.back)).getBitmap();//“返回”的图片}ButtonStart = new ButtonUtil(imgStart,(scrWidth - imgStart.getWidth())/2,100);//把“开始游戏”的图片与按钮绑定ButtonHelp = new ButtonUtil(imgHelp,(scrWidth - imgHelp.getWidth())/2,200);ButtonScore = new ButtonUtil(imgScore,(scrWidth - imgScore.getWidth())/2,300);ButtonDetail = new ButtonUtil(imgDetail,(scrWidth - imgDetail.getWidth())/2,400);ButtonReturn = new ButtonUtil(imgReturn,scrWidth - imgReturn.getWidth() - 10,scrHeight - 50);//把“返回”的图片与按钮绑定GameState = GameState.GAMESTATE_MENU; //状态转换成菜单状态}public void TurnToLeverGuide()//进入选关{ReleaseImage(imgBackground);imgBackground =((BitmapDrawable)getResources().getDrawable(R.drawable.bg2)).getBitmap();//背景图片if (imgFirst == null){imgFirst = ((BitmapDrawable)getResources().getDrawable(R.drawable.firstlever)).getBitmap();//“第1关”的图片}if (imgSecond == null){imgSecond = ((BitmapDrawable)getResources().getDrawable(R.drawable.secondlever)).getBitmap();//“第2关”的图片}ButtonFirst = new ButtonUtil(imgFirst,(scrWidth - imgFirst.getWidth())/2,150);ButtonSecond = new ButtonUtil(imgSecond,(scrWidth - imgSecond.getWidth())/2,300);GameState = GameState.GAMESTATE_LEVELGUIDE;}public void TurnToHelp()//进入帮助{if (imgHelpDisplay == null){imgHelpDisplay = ((BitmapDrawable)getResources().getDrawable(R.drawable.helpdisplay)).getBitmap();}GameState = GameState.GAMESTATE_HELP;}public void TurnToScore()//进入高分榜{if (imgScoreDisplay == null){TextView a=new TextView(context);a.setText("a");//imgScoreDisplay = ((BitmapDrawable)getResources().getDrawable(R.drawable.scoredisplay)).getBitmap();}GameState = GameState.GAMESTATE_SCORE;}public void TurnToDetail()//进入信息{if (imgDetailDisplay == null){imgDetailDisplay = ((BitmapDrawable)getResources().getDrawable(R.drawable.detaildisplay)).getBitmap();}GameState = GameState.GAMESTATE_DETAIL;}public void TurnToGame()//进入游戏{   LoadResource();InitLever();//GameState = GameState.GAMESTATE_GAME;//////////为背景图定义了SpriteCmd类的两个对象,为背景图设定两个位置同时画出来//// rgBackground1.x = 0;rgBackground1.y = -scrHeight;rgBackground1.unLayer = 0;rgBackground1.unWidth = scrWidth;  //背景图的宽度设为全屏rgBackground1.unHeight = scrHeight;//背景图的宽度设为全屏rgBackground2.x = 0;rgBackground2.y = 0;rgBackground2.unLayer = 0;rgBackground2.unWidth = scrWidth;//背景图的宽度设为全屏rgBackground2.unHeight = scrHeight; //背景图的宽度设为全屏///////////////////////////////////////////////////////////// imgSoundOn =((BitmapDrawable)getResources().getDrawable(R.drawable.bgsoundon)).getBitmap();imgSoundOff =((BitmapDrawable)getResources().getDrawable(R.drawable.bgsoundoff)).getBitmap();ButtonSound = new ButtonUtil(imgSoundOn,10,scrHeight - 20);rgLerver.unWidth = 200;rgLerver.unHeight = 40;rgLerver.unLayer = 255;rgGameover.unWidth = 200;rgGameover.unHeight = 40;rgGameover.unLayer = 255;rgBloodBg.unWidth = 100;rgBloodBg.unHeight = 32;rgBloodBg.unLayer = 0;rgBloodBg.x = 0;rgBloodBg.y = 0;rgBlood.unWidth = 96;rgBlood.unHeight = 14;rgBlood.unLayer = 0;rgBlood.x = rgBloodBg.x;rgBlood.y = rgBloodBg.y   10;mediaPlayer = MediaPlayer.create(context, R.raw.game);    mediaPlayer.start();    mediaPlayer.setLooping(true);is_LeverUp = false;}void InitLever(){int i;switch (LeverNum) {case 1:   //第一关rgSpriteCmd.unWidth = 36;rgSpriteCmd.unHeight = 34;rgSpriteCmd.x = (scrWidth - rgSpriteCmd.unWidth)/2;rgSpriteCmd.y = scrHeight - rgSpriteCmd.unHeight;rgSpriteCmd.unLayer = 0;rgSpriteCmd.unSpriteIndex = 0;rgSpriteCmd.CurrentState = MainState.enSTAND;rgSpriteCmd.WalkCount = 0;rgSpriteCmd.IsHurt = false;rgSpriteCmd.IsLeftStop = false;rgSpriteCmd.IsRight = false;rgSpriteCmd.IsTopStop = false;rgSpriteCmd.IsDownStop = false;//敌人初始化rgEnemy1Cmd.unWidth = 35;rgEnemy1Cmd.unHeight = 30;rgEnemy1Cmd.unLayer = 255;rgEnemy3Cmd.unWidth = 35;rgEnemy3Cmd.unHeight = 30;rgEnemy3Cmd.unLayer = 255;rgEnemy3Cmd.IsRight = false;rgEnemy4Cmd.unWidth = 35;rgEnemy4Cmd.unHeight = 30;rgEnemy4Cmd.unLayer = 255;rgEnemy4Cmd.IsRight = false;break;case 2:  //第二关rgSpriteCmd.unWidth = 36;rgSpriteCmd.unHeight = 34;rgSpriteCmd.x = (scrWidth - rgSpriteCmd.unWidth)/4;rgSpriteCmd.y = scrHeight - rgSpriteCmd.unHeight;rgSpriteCmd.unLayer = 0;rgSpriteCmd.unSpriteIndex = 0;rgSpriteCmd.CurrentState = MainState.enSTAND;rgSpriteCmd.WalkCount = 0;rgSpriteCmd.IsHurt = false;rgSpriteCmd.IsLeftStop = false;rgSpriteCmd.IsRight = false;rgSpriteCmd.IsTopStop = false;rgSpriteCmd.IsDownStop = false;//敌人初始化rgEnemy1Cmd.unWidth = 35;rgEnemy1Cmd.unHeight = 30;rgEnemy1Cmd.unLayer = 255;rgEnemy2Cmd.unWidth = 35;rgEnemy2Cmd.unHeight = 30;rgEnemy2Cmd.unLayer = 255;rgEnemy3Cmd.unWidth = 35;rgEnemy3Cmd.unHeight = 30;rgEnemy3Cmd.unLayer = 255;rgEnemy3Cmd.IsRight = false;rgEnemy4Cmd.unWidth = 35;rgEnemy4Cmd.unHeight = 30;rgEnemy4Cmd.unLayer = 255;rgEnemy5Cmd.unWidth = 35;rgEnemy5Cmd.unHeight = 30;rgEnemy5Cmd.unLayer = 255;rgEnemy5Cmd.IsRight = false;break;default:break;}////星星的初始化///////////////////////////////for (i = 0; i < STAR_NUM; i  = 1){rgCmdStar[i] = new SpriteCmd();//每颗星星都实例化SpriteCmd类对象}for (i = 0; i < STAR_NUM; i  = 2) //偶数个星星的图片索引值为0{rgCmdStar[i].unSpriteIndex = 0;}for (i = 1; i < STAR_NUM; i  = 2) //基数个星星的图片索引值为1{rgCmdStar[i].unSpriteIndex = 1;}for (i = 0; i < STAR_NUM; i   ){rgCmdStar[i].unWidth = 3; //每颗星星图片的宽度和高度rgCmdStar[i].unHeight = 3;rgCmdStar[i].x = scrWidth/STAR_NUM*i   10;//每颗星星图片绘制在屏幕上的位置rgCmdStar[i].y = scrHeight/STAR_NUM*i;} //////////////每颗子弹实例化SpriteCmd类对象,初始化////////for(i=0;i scrHeight) {//到达地图下边界rgSpriteCmd.IsDownStop = true;rgSpriteCmd.y = scrHeight - rgSpriteCmd.unHeight;}else {rgSpriteCmd.IsDownStop = false;}////主机与敌机的碰撞判断及处理///////////////////////////////if ((CheckHitEnemy(rgSpriteCmd, rgEnemy1Cmd) || CheckHitEnemy(rgSpriteCmd, rgEnemy2Cmd)|| CheckHitEnemy(rgSpriteCmd, rgEnemy3Cmd)) || CheckHitEnemy(rgSpriteCmd, rgEnemy4Cmd)|| CheckHitEnemy(rgSpriteCmd, rgEnemy5Cmd)&& !rgSpriteCmd.IsHurt) {rgSpriteCmd.CurrentState = MainState.enHURT;rgSpriteCmd.ProtectCount = 18;rgSpriteCmd.IsHurt = true;rgBlood.unWidth -= 19;if (rgBlood.unWidth < 0) {rgBlood.unWidth = 96;}}/////主机子弹与敌机1的碰撞////////////////////////////////for(i=0;i -1 && y_sensor < 1) {rgSpriteCmd.CurrentState = MainState.enSTAND;}else {rgSpriteCmd.unSpriteIndex = 0;rgSpriteCmd.y  = 10;}}else if (rgSpriteCmd.CurrentState == MainState.enHURT) {rgSpriteCmd.unSpriteIndex = MainTime%2 - 1; rgSpriteCmd.ProtectCount--;if (rgSpriteCmd.ProtectCount == 0) {rgSpriteCmd.CurrentState = MainState.enSTAND;rgSpriteCmd.IsHurt = false;}}}   ///////把图片画成全屏///////////////////////////////////////////public  void DisplayImage(Canvas canvas, Bitmap bitmap,int width, int height){    if(bitmap!=null)    {    Rect scrRect = new Rect(); //绘制区域在屏幕上的矩形范围        scrRect.left = 0; //绘制区域左上角顶点在屏幕上的x坐标        scrRect.top = 0; //绘制区域左上角顶点在屏幕上的y坐标        scrRect.right = scrWidth;//width; //绘制区域右下角顶点在屏幕上的x坐标        scrRect.bottom = scrHeight;//height; //绘制区域右下角顶点在屏幕上的y坐标        Rect imgRect = new Rect(); //绘制区域在图片上的矩形范围        imgRect.left = 0; //绘制区域左上角顶点距离图片左上角的x坐标        imgRect.top = 0; //绘制区域左上角顶点距离图片左上角的y坐标        imgRect.right = 0   width; //绘制区域右下角顶点距离图片左上角的x坐标        imgRect.bottom = 0   height; //绘制区域右下角顶点距离图片左上角的y坐标        canvas.drawBitmap(bitmap, imgRect, scrRect, null); //绘制图片    }    }///////////////////////////////////////////////////////////////////////////  ////////画精灵(相对于屏幕的相对位置)//////////////////////public   void DrawSprites(Canvas canvas, Bitmap bitmap, SpriteCmd spriteCmd){if (spriteCmd.unLayer != 255) {DisplayImage(canvas, bitmap, //要画的图片spriteCmd.x, //图片左上角画在屏幕上的x位置spriteCmd.y, //图片左上角画在屏幕上的y位置spriteCmd.unWidth, //图片的宽度spriteCmd.unHeight, //图片的高度0, //要画的图片在整个图片中的x方向位置spriteCmd.unSpriteIndex * spriteCmd.unHeight); //要画的图片在整个图片中的y方向位置}}//画图片//参数依次为画布Canvas对象,位图对象,在屏幕上的x坐标,在屏幕上的y坐标,//绘制的宽度,绘制的高度,在图片上的x坐标,在图片上的y坐标public  void DisplayImage(Canvas canvas, Bitmap bitmap, int scrX, int scrY, int width, int height, int imgX, int imgY){if(bitmap!=null){Rect scrRect = new Rect(); //绘制区域在屏幕上的矩形范围scrRect.left = scrX; //绘制区域左上角顶点在屏幕上的x坐标scrRect.top = scrY; //绘制区域左上角顶点在屏幕上的y坐标scrRect.right = scrX   width; //绘制区域右下角顶点在屏幕上的x坐标scrRect.bottom = scrY   height; //绘制区域右下角顶点在屏幕上的y坐标Rect imgRect = new Rect(); //绘制区域在图片上的矩形范围imgRect.left = imgX; //绘制区域左上角顶点距离图片左上角的x坐标imgRect.top = imgY; //绘制区域左上角顶点距离图片左上角的y坐标imgRect.right = imgX   width; //绘制区域右下角顶点距离图片左上角的x坐标imgRect.bottom = imgY   height; //绘制区域右下角顶点距离图片左上角的y坐标canvas.drawBitmap(bitmap, imgRect, scrRect, null); //绘制图片}}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////触屏事件////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////public boolean onTouchEvent(MotionEvent event){switch (event.getAction()){case MotionEvent.ACTION_DOWN: // 当触摸到屏幕IsRightKeyRealess = false;IsLeftKeyRealess = false;IsUpKeyRealess = false;IsDownKeyRealess = false;switch (GameState){case GAMESTATE_MENU:onTouchEventInMenu(event); // 菜单界面的触屏事件处理break;case GAMESTATE_LEVELGUIDE:onTouchEventLeverGuide(event);// 选关界面的触屏事件处理break;case GAMESTATE_HELP:onTouchEventHelp(event);// 帮助界面的触屏事件处理break;case GAMESTATE_SCORE:onTouchEventScore(event);// 分数界面的触屏事件处理break;case GAMESTATE_DETAIL:onTouchEventHelp(event);// 信息界面的触屏事件处理break;case GAMESTATE_GAME:onTouchEventInGame(event);// 游戏界面的触屏事件处理break;default:break;}return true;case MotionEvent.ACTION_UP:// 当手抬起,离开屏幕IsRightKeyRealess = true;IsLeftKeyRealess = true;IsUpKeyRealess = true;IsDownKeyRealess = true;return true;default:break;} return super.onTouchEvent(event);}public void onTouchEventInMenu(MotionEvent event)// 菜单界面的触屏事件处理{float x, y;x = event.getX();y = event.getY();if (ButtonStart.isClick(x, y)) {TurnToLeverGuide();}else if (ButtonHelp.isClick(x, y)) {TurnToHelp();}else if (ButtonScore.isClick(x, y)) {TurnToScore();}else if (ButtonDetail.isClick(x, y)) {TurnToDetail();}else if (ButtonReturn.isClick(x, y)) {Is_exit = true;CloseGame();}}public void onTouchEventLeverGuide(MotionEvent event)// 选关界面的触屏事件处理{float x, y;x = event.getX();y = event.getY();if (ButtonReturn.isClick(x, y)) {TurnToMenu();}else if (ButtonFirst.isClick(x, y)) {LeverNum = 1;TurnToGame();}else if (ButtonSecond.isClick(x, y)) {LeverNum = 2;TurnToGame();}}public void onTouchEventHelp(MotionEvent event)// 帮助界面的触屏事件处理{float x, y;x = event.getX();y = event.getY();if (ButtonReturn.isClick(x, y)) {TurnToMenu();}}public void onTouchEventScore(MotionEvent event)// 帮助界面的触屏事件处理{float x, y;x = event.getX();y = event.getY();if (ButtonReturn.isClick(x, y)) {TurnToMenu();}}public void onTouchEventInGame(MotionEvent event)// 游戏界面的触屏事件处理{float x, y;x = event.getX();y = event.getY();//////处理返回键/////////////////////////////// if (ButtonReturn.isClick(x, y)) {TurnToMenu();mediaPlayer.pause();}/////////////////////////////////////////// ///////////////声音处理///////////////////////////else if(ButtonSound.isClick(x, y)){if (is_SoundOn) {ButtonSound.setButtonPic(imgSoundOff);is_SoundOn = false;mediaPlayer.pause();}else {ButtonSound.setButtonPic(imgSoundOn);is_SoundOn = true;    mediaPlayer.start();    mediaPlayer.setLooping(true);}}/////////////////////////////////////////////////////////////////根据触摸点的位置判断主角飞机的运动状态////////////////////if ((x- rgSpriteCmd.x - rgSpriteCmd.unWidth/2) > (y - rgSpriteCmd.y - rgSpriteCmd.unHeight / 2)&& (x- rgSpriteCmd.x - rgSpriteCmd.unWidth/2) > -(y - rgSpriteCmd.y - rgSpriteCmd.unHeight / 2)&& !rgSpriteCmd.IsRigtStop && rgSpriteCmd.CurrentState != MainState.enHURT &&!ButtonSound.isClick(x, y)){rgSpriteCmd.CurrentState = MainState.enWALKRIGHT;//向右走}else if ((x - rgSpriteCmd.x - rgSpriteCmd.unWidth / 2 < (y - rgSpriteCmd.y - rgSpriteCmd.unHeight / 2)) && (x- rgSpriteCmd.x - rgSpriteCmd.unWidth/2) < -(y - rgSpriteCmd.y - rgSpriteCmd.unHeight / 2)&& !rgSpriteCmd.IsLeftStop && rgSpriteCmd.CurrentState != MainState.enHURT &&!ButtonSound.isClick(x, y)){rgSpriteCmd.CurrentState = MainState.enWALKLEFT;//向左走}else if ((y - rgSpriteCmd.y - rgSpriteCmd.unHeight / 2) = (x - rgSpriteCmd.x - rgSpriteCmd.unWidth / 2) && (y - rgSpriteCmd.y - rgSpriteCmd.unHeight / 2) >= -(x - rgSpriteCmd.x - rgSpriteCmd.unWidth / 2)&& !rgSpriteCmd.IsDownStop && rgSpriteCmd.CurrentState != MainState.enHURT &&!ButtonSound.isClick(x, y)){rgSpriteCmd.CurrentState = MainState.enWALKDOWN;//向下走}}/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public Boolean  CheckHitEnemy(SpriteCmd Cmd,SpriteCmd SpCmd) {if (Cmd.unLayer!=255 && SpCmd.unLayer != 255) {if (Cmd.x   Cmd.unWidth > SpCmd.x && Cmd.x < SpCmd.x   SpCmd.unWidth &&    Cmd.y   Cmd.unHeight > SpCmd.y && Cmd.y < SpCmd.y   SpCmd.unHeight) {return true;}} return false;}/////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void onAccuracyChanged(Sensor sensor, int accuracy) {// TODO Auto-generated method stub}public void onSensorChanged(SensorEvent event) {// TODO Auto-generated method stubx_sensor = event.values[0]; // 手机横向翻滚// x>0 说明当前手机左翻 x0 说明当前手机下翻 y0 手机屏幕朝上 z
    2015-07-02下载
    积分:1
  • 代码学习
    安卓代码学习,H265最新技术,下载可以编辑。请广大朋友放心下载学习与交流。 安卓代码学习,H265最新技术,下载可以编辑。请广大朋友放心下载学习与交流。
    2022-04-19 06:34:14下载
    积分:1
  • 安卓应用小APP
    一个安卓手机上的小App,随手记,关于记录衣食住行的,是Android开发入门的比较好的小项目。
    2022-07-16 20:15:48下载
    积分:1
  • contacts_API
    An android program for building contact and associated apps...
    2014-05-13 12:39:08下载
    积分:1
  • 696518资源总数
  • 104297会员总数
  • 29今日下载