登录
首页 » Android » Android创建圆形和混合阴影渐变特效

Android创建圆形和混合阴影渐变特效

于 2022-03-16 发布 文件大小:93.18 kB
0 58
下载积分: 2 下载次数: 1

代码说明:

这是一个Android生成渐变的例子,比如生成圆形渐变、角度渐变、混合渐变等,并叠加了位图和线性特性,如示例截图所示,仅为其中一种渐变,代码中对几种渐变给出了注释和具体代码,对于学习Android graphics类下的相关属性方法有很好的借鉴意义:   protected void onDraw(Canvas canvas) {   //位图   //shader = new BitmapShader(b, TileMode.REPEAT, TileMode.MIRROR);   //线性   int[] colors = new int[]{    Color.RED,Color.GREEN,Color.BLUE   };   //shader = new LinearGradient(0, 0, 100, 100, colors, null, TileMode.REPEAT);   //圆形渐变   //shader = new RadialGradient(100, 100, 80, colors, null, TileMode.REPEAT);   //角度渐变   //shader = new SweepGradient(160, 160, colors, null);   //混合渐变   Shader shader1 = new LinearGradient(0, 0, 100, 100, colors, null, TileMode.REPEAT);   Shader shader2 = new RadialGradient(100, 100, 80, colors, null, TileMode.REPEAT);   shader = new ComposeShader(shader1, shader2, PorterDuff.Mode.DARKEN);   paint = new Paint();   paint.setShader(shader);   paint.setColor(Color.BLUE);   canvas.drawRect(0, 0, 500, 500, paint);   }

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

发表评论

0 个回复

  • listview三种添加方法
    ListView是Android软件开发中非常重要组件之一,基本上是个软件基本都会使用ListView ,今天我通过一个demo来教大家怎么样使用ListView组件 绘制出漂亮的列表,说道ListView就不得不说Adapter适配器,因为只有通过Adapter才可以把列表中的数据映射到ListView中。在android的开发中最Adapter 一共可以分为ArrayAdapter,BaseAdapter, CursorAdapter,HeaderViewListAdapter, ResourceCursorAdapter,SimpleAdapter,SimpleCursorAdapter,WrapperListAdapter软件开发中最常用的有ArrayAdapter, BaseAdapter, SimpleAdapter,今天我用一段代码向大家诠释如何使用ListView控件。
    2022-03-24 20:54:27下载
    积分: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
  • MarqueeView-master
    说明:  Android平台比较好用滚动通知效果,可以进行点击事件。(Android platform is better to use scroll notification effect, you can click events.)
    2020-06-20 06:00:01下载
    积分:1
  • 基于wifi的手机和stm32单片机通信的安卓程序
    应用背景现在智能家居很火,很多是基于wifi技术的,这个时候如果用手机控制是很方便的,因为大家知道我们的手机都有wifi的功能,就可以用手机控制,而不需要以前的遥控器了。这个安卓应用程序,只要是应用了stm32单片机的设备,都可以用这个安卓程序控制,可以应用到智能家居,或者其他控制电机的场合。关键技术这个安卓程序使用eclips写的,直接用eclips打开就可以看到工程的源代码,主要是作为一个上位机来用,基于wifi的,很方便,有按键和直接输入命令两种模式,在单片机上需要连一个路由器,路由器就构建了一个小局域网,这个单片机就和手机处于一个局域网内,路由器在这里并不需要联网。
    2022-10-12 10:50:04下载
    积分:1
  • Android 魔塔游戏-源代码
    这是一款Android 魔塔游戏-源代码,游戏功能:"新游戏", "读取上次游戏", "帮助", "关于"。   可研究学习学习下同类游戏的写法,比如初始化游戏,得到游戏状态,设置游戏状态,得到主类对象,得到当前需要显示的对象等。游戏界面如下图所示。
    2023-01-28 08:45:03下载
    积分:1
  • TVINFOR4.04
    allwinner a10 AV-IN驱动及android DEMO
    2013-10-22 15:42:24下载
    积分:1
  • Alakazam-master
    Wifi location Android
    2014-12-16 07:05:26下载
    积分:1
  • listview列表
    基于安卓的简单的listview列表显示数据
    2022-10-10 14:15:03下载
    积分:1
  • Android实现表单上传文件
    Android的HttpURLConnections等并不能直接实现表单形式上传文件,必须另类实现。注册时一般是先利用表单上传头像图片得到头像在服务器的地址,再将得到的地址和其它注册信息提交。
    2022-10-22 16:35:03下载
    积分:1
  • android 单选菜单 menu实例 附源码
    listview 单选菜单实例,详见截图
    2013-03-03下载
    积分:1
  • 696518资源总数
  • 104292会员总数
  • 28今日下载