Android_(游戏)打飞机04:绘画敌机、添加子弹

 

 

 

(游戏)打飞机01:前言  传送门

(游戏)打飞机02:游戏背景滚动  传送门

(游戏)打飞机03:控制玩家飞机   传送门 

(游戏)打飞机04:绘画敌机、添加子弹    传送门

(游戏)打飞机05:处理子弹,击中敌机,添加计分板   传送门

(游戏)打飞机06:后续  传送门

 

 

 

绘画敌机、添加子弹效果

 

 

package com.example.administrator.myapplication;import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;import java.util.ArrayList;
import java.util.List;
import java.util.Random;/*** Created by Administrator on 2018/8/9.*/public class dafeijiGameView extends SurfaceView implementsSurfaceHolder.Callback,Runnable,android.view.View.OnTouchListener{private Bitmap my;//自己private Bitmap baozha;//爆炸private Bitmap bg;//背景private Bitmap diren;//敌人private Bitmap zidan;//子弹private Bitmap erjihuancun;//二级缓存private WindowManager windowManager;//获得界面长宽高private int display_w;  //界面的宽private int display_h;  //界面的高private ArrayList<GameImage> gameImage = new ArrayList();private ArrayList<Zidan> zidans = new ArrayList<Zidan>();public dafeijiGameView(Context context) {super(context);getHolder().addCallback(this);//事件注册this.setOnTouchListener(this);}private void init(){//加载照片my= BitmapFactory.decodeResource(getResources(),R.drawable.my);baozha= BitmapFactory.decodeResource(getResources(),R.drawable.baozha);bg= BitmapFactory.decodeResource(getResources(),R.drawable.bg);diren= BitmapFactory.decodeResource(getResources(),R.drawable.diren);zidan= BitmapFactory.decodeResource(getResources(),R.drawable.zidan);erjihuancun=Bitmap.createBitmap(display_w,display_h, Bitmap.Config.ARGB_8888);gameImage.add(new BeijingImage(bg));    //先加入背景照片gameImage.add(new FeijiImage(my));gameImage.add(new DijiImage(diren));}FeijiImage selectfeiji;@Overridepublic boolean onTouch(View v, MotionEvent event) {//手接近屏幕产生的事件if(event.getAction()==MotionEvent.ACTION_DOWN){for(GameImage game: gameImage){if(game instanceof FeijiImage){FeijiImage feiji = (FeijiImage)game;//判断条件为真时选中飞机if(feiji.getX()<event.getX()&&feiji.getY()<event.getY()&&feiji.getX()+feiji.getWidth()>event.getX() &&feiji.getY()+feiji.getHeigth()>event.getY()){selectfeiji=feiji;}else{selectfeiji=null;}break;}}}else if(event.getAction()==MotionEvent.ACTION_MOVE){//移动鼠标if( selectfeiji!=null){selectfeiji.setX((int)event.getX()-selectfeiji.getWidth()/2);selectfeiji.setY((int)event.getY()-selectfeiji.getHeigth()/2);}}else if(event.getAction()==MotionEvent.ACTION_UP){//松开鼠标selectfeiji=null;}return true;}private interface GameImage{public Bitmap getBitmap();public int getX();public int getY();}private class Zidan implements GameImage{Bitmap zidan;private FeijiImage feiji;private int x;private int y;public Zidan(FeijiImage feiji,Bitmap zidan){this.feiji=feiji;this.zidan=zidan;x=(feiji.getX()+feiji.getWidth()/2)-25;//居中位置y=feiji.getY()-zidan.getHeight();}public Bitmap getBitmap() {y-=19;if(y<=-10){zidans.remove(this);}return zidan;}@Overridepublic int getX() {return x;}@Overridepublic int getY() {return y;}}private class DijiImage implements GameImage{private Bitmap diren = null;private List<Bitmap> bitmaps = new ArrayList<Bitmap>();private int x;private int y;public DijiImage(Bitmap diren){this.diren=diren;bitmaps.add(Bitmap.createBitmap(diren,0,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*1,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*2,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*3,0,diren.getWidth()/4,diren.getHeight()));y=-diren.getHeight();Random ran = new Random();x=ran.nextInt(display_w-(diren.getWidth()/4));}private int index=0;private int num =0;@Overridepublic Bitmap getBitmap() {Bitmap bitmap = bitmaps.get(index);//控制切换四个飞机的频率if(num == 7){index++;if(index == bitmaps.size()){index=0;}num=0;}y+=3;num++;if(y>display_h){gameImage.remove(this);}return bitmap;}@Overridepublic int getX() {return x;}@Overridepublic int getY() {return y;}}private class FeijiImage implements GameImage{private Bitmap my;private int x;private int y;private int width;private int heigth;private int getWidth(){return width;}private int getHeigth(){return heigth;}private List<Bitmap> bitmaps = new ArrayList<Bitmap>();private  FeijiImage(Bitmap my){this.my=my;bitmaps.add(Bitmap.createBitmap(my,0,0,my.getWidth()/4,my.getHeight()));bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4),0,my.getWidth()/4,my.getHeight()));bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4)*2,0,my.getWidth()/4,my.getHeight()));bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4)*3,0,my.getWidth()/4,my.getHeight()));//得到战机的高和宽width=my.getWidth()/4;heigth=my.getHeight();x=(display_w - my.getWidth()/4)/2;y=display_h-my.getHeight()-30;}private int index=0;private int num =0;@Overridepublic Bitmap getBitmap() {Bitmap bitmap = bitmaps.get(index);//控制切换四个飞机的频率if(num == 7){index++;if(index == bitmaps.size()){index=0;}num=0;}num++;return bitmap;}@Overridepublic int getX() {return x;}@Overridepublic int getY() {return y;}public void setY(int y){this.y=y;}public void setX(int x){this.x=x;}}//负责背景照片的处理private class BeijingImage implements GameImage{private Bitmap bg;private BeijingImage(Bitmap bg){this.bg=bg;newBitmap = Bitmap.createBitmap(display_w,display_h, Bitmap.Config.ARGB_8888);}private Bitmap newBitmap = null;private int height = 0;public Bitmap getBitmap(){Paint p = new Paint();Canvas canvas = new Canvas(newBitmap);canvas.drawBitmap(bg,new Rect(0,0,bg.getWidth(),bg.getHeight()),new Rect(0,height,display_w,display_h+height),p);canvas.drawBitmap(bg,new Rect(0,0,bg.getWidth(),bg.getHeight()),new Rect(0,-display_h+height,display_w,height),p);height++;if(height==display_h){height=0;}return newBitmap;}public int getX(){return 0;}public int getY(){return 0;}}private boolean state = false;private SurfaceHolder holder;//绘画中心public void run() {Paint p1 = new Paint();int diren_num=0;//
        int zidan_num=0;try{while(state){if(selectfeiji!=null){if(zidan_num==10){zidans.add(new Zidan(selectfeiji,zidan));zidan_num=0;}zidan_num++;}Canvas newCanvas = new Canvas(erjihuancun);for(GameImage image:(List<GameImage>)gameImage.clone()){newCanvas.drawBitmap(image.getBitmap(),image.getX(),image.getY(),p1);}for(GameImage image:(List<GameImage>)zidans.clone()){newCanvas.drawBitmap(image.getBitmap(),image.getX(),image.getY(),p1);}if(diren_num==150){diren_num=0;gameImage.add(new DijiImage(diren));}diren_num++;Canvas canvas = holder.lockCanvas();canvas.drawBitmap(erjihuancun,0,0,p1);holder.unlockCanvasAndPost(canvas);Thread.sleep(10);}}catch(Exception e){}}@Overridepublic void surfaceCreated(SurfaceHolder holder) {}@Overridepublic void surfaceDestroyed(SurfaceHolder holder) {state = false;}@Overridepublic void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {//得到屏幕的宽和高display_w=width;display_h=height;init();this.holder=holder;state = true;new Thread(this).start();}}
dafeijiGameView.java

 

package com.example.administrator.myapplication;import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;public class MainActivity extends AppCompatActivity{@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);//去掉标题// requestWindowFeature(Window.FEATURE_NO_TITLE);dafeijiGameView view =  new dafeijiGameView(this);setContentView(view);}}
MainActivity.java

 

实现过程

 

  绘制敌机

 

   private class DijiImage implements GameImage{private Bitmap diren = null;private List<Bitmap> bitmaps = new ArrayList<Bitmap>();private int x;private int y;public DijiImage(Bitmap diren){this.diren=diren;bitmaps.add(Bitmap.createBitmap(diren,0,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*1,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*2,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*3,0,diren.getWidth()/4,diren.getHeight()));y=-diren.getHeight();Random ran = new Random();x=ran.nextInt(display_w-(diren.getWidth()/4));}private int index=0;private int num =0;@Overridepublic Bitmap getBitmap() {Bitmap bitmap = bitmaps.get(index);//控制切换四个飞机的频率if(num == 7){index++;if(index == bitmaps.size()){index=0;}num=0;}y+=3;num++;if(y>display_h){gameImage.remove(this);}return bitmap;}@Overridepublic int getX() {return x;}@Overridepublic int getY() {return y;}}
DijiImage.java

 

  初始化游戏时候加载敌机类

    private void init(){//加载照片my= BitmapFactory.decodeResource(getResources(),R.drawable.my);baozha= BitmapFactory.decodeResource(getResources(),R.drawable.baozha);bg= BitmapFactory.decodeResource(getResources(),R.drawable.bg);diren= BitmapFactory.decodeResource(getResources(),R.drawable.diren);zidan= BitmapFactory.decodeResource(getResources(),R.drawable.zidan);erjihuancun=Bitmap.createBitmap(display_w,display_h, Bitmap.Config.ARGB_8888);gameImage.add(new BeijingImage(bg));    //先加入背景照片gameImage.add(new FeijiImage(my));gameImage.add(new DijiImage(diren));}

 

  绘制敌机飞行动画

private List<Bitmap> bitmaps = new ArrayList<Bitmap>();

 

  将四张敌机加入链表

       bitmaps.add(Bitmap.createBitmap(diren,0,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*1,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*2,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*3,0,diren.getWidth()/4,diren.getHeight()));

 

 public static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter)
  从原始位图剪切图像,这是一种高级的方式。可以用Matrix(矩阵)来实现旋转等高级方式截图
  

参数说明:  传送门
    Bitmap source:要从中截图的原始位图
    int x:起始x坐标
    int y:起始y坐标
    int width:要截的图的宽度
    int height:要截的图的宽度
    Bitmap.Config  config:一个枚举类型的配置,可以定义截到的新位图的质量

  返回值:返回一个剪切好的Bitmap 
  绘制飞机飞行动画(不断切换四张图片,看起来像飞机飞)
 private int index=0;private int num =0;@Overridepublic Bitmap getBitmap() {Bitmap bitmap = bitmaps.get(index);//控制切换四个飞机的频率if(num == 7){index++;if(index == bitmaps.size()){index=0;}num=0;}//y+=3控制敌机下降速度y+=3;        

 

  随机位置生成敌机

            y=-diren.getHeight();Random ran = new Random();x=ran.nextInt(display_w-(diren.getWidth()/4));

 

  在游戏绘画中心中添加敌机出现

//绘画中心public void run() {Paint p1 = new Paint();int diren_num=0;//
        try{while(true){Canvas newCanvas = new Canvas(erjihuancun);for(GameImage image:(List<GameImage>)gameImage.clone()){newCanvas.drawBitmap(image.getBitmap(),image.getX(),image.getY(),p1);}if(diren_num==150){diren_num=0;gameImage.add(new DijiImage(diren));}diren_num++;Canvas canvas = holder.lockCanvas();canvas.drawBitmap(erjihuancun,0,0,p1);holder.unlockCanvasAndPost(canvas);Thread.sleep(10);}}catch(Exception e){}}

 

  敌机出现频率

                if(diren_num==150){diren_num=0;gameImage.add(new DijiImage(diren));}diren_num++;

 

 

 

package com.example.administrator.myapplication;import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;import java.util.ArrayList;
import java.util.List;
import java.util.Random;/*** Created by Administrator on 2018/8/9.*/public class dafeijiGameView extends SurfaceView implementsSurfaceHolder.Callback,Runnable,android.view.View.OnTouchListener{private Bitmap my;//自己private Bitmap baozha;//爆炸private Bitmap bg;//背景private Bitmap diren;//敌人private Bitmap zidan;//子弹private Bitmap erjihuancun;//二级缓存private WindowManager windowManager;//获得界面长宽高private int display_w;  //界面的宽private int display_h;  //界面的高private ArrayList<GameImage> gameImage = new ArrayList();public dafeijiGameView(Context context) {super(context);getHolder().addCallback(this);//事件注册this.setOnTouchListener(this);}private void init(){//加载照片my= BitmapFactory.decodeResource(getResources(),R.drawable.my);baozha= BitmapFactory.decodeResource(getResources(),R.drawable.baozha);bg= BitmapFactory.decodeResource(getResources(),R.drawable.bg);diren= BitmapFactory.decodeResource(getResources(),R.drawable.diren);zidan= BitmapFactory.decodeResource(getResources(),R.drawable.zidan);erjihuancun=Bitmap.createBitmap(display_w,display_h, Bitmap.Config.ARGB_8888);gameImage.add(new BeijingImage(bg));    //先加入背景照片gameImage.add(new FeijiImage(my));gameImage.add(new DijiImage(diren));}FeijiImage selectfeiji;@Overridepublic boolean onTouch(View v, MotionEvent event) {//手接近屏幕产生的事件if(event.getAction()==MotionEvent.ACTION_DOWN){for(GameImage game: gameImage){if(game instanceof FeijiImage){FeijiImage feiji = (FeijiImage)game;//判断条件为真时选中飞机if(feiji.getX()<event.getX()&&feiji.getY()<event.getY()&&feiji.getX()+feiji.getWidth()>event.getX() &&feiji.getY()+feiji.getHeigth()>event.getY()){selectfeiji=feiji;}else{selectfeiji=null;}break;}}}else if(event.getAction()==MotionEvent.ACTION_MOVE){//移动鼠标if( selectfeiji!=null){selectfeiji.setX((int)event.getX()-selectfeiji.getWidth()/2);selectfeiji.setY((int)event.getY()-selectfeiji.getHeigth()/2);}}else if(event.getAction()==MotionEvent.ACTION_UP){//松开鼠标selectfeiji=null;}return true;}private interface GameImage{public Bitmap getBitmap();public int getX();public int getY();}private class DijiImage implements GameImage{private Bitmap diren = null;private List<Bitmap> bitmaps = new ArrayList<Bitmap>();private int x;private int y;public DijiImage(Bitmap diren){this.diren=diren;bitmaps.add(Bitmap.createBitmap(diren,0,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*1,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*2,0,diren.getWidth()/4,diren.getHeight()));bitmaps.add(Bitmap.createBitmap(diren,(diren.getWidth()/4)*3,0,diren.getWidth()/4,diren.getHeight()));y=-diren.getHeight();Random ran = new Random();x=ran.nextInt(display_w-(diren.getWidth()/4));}private int index=0;private int num =0;@Overridepublic Bitmap getBitmap() {Bitmap bitmap = bitmaps.get(index);//控制切换四个飞机的频率if(num == 7){index++;if(index == bitmaps.size()){index=0;}num=0;}y+=3;num++;if(y>display_h){gameImage.remove(this);}return bitmap;}@Overridepublic int getX() {return x;}@Overridepublic int getY() {return y;}}private class FeijiImage implements GameImage{private Bitmap my;private int x;private int y;private int width;private int heigth;private int getWidth(){return width;}private int getHeigth(){return heigth;}private List<Bitmap> bitmaps = new ArrayList<Bitmap>();private  FeijiImage(Bitmap my){this.my=my;bitmaps.add(Bitmap.createBitmap(my,0,0,my.getWidth()/4,my.getHeight()));bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4),0,my.getWidth()/4,my.getHeight()));bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4)*2,0,my.getWidth()/4,my.getHeight()));bitmaps.add(Bitmap.createBitmap(my,(my.getWidth()/4)*3,0,my.getWidth()/4,my.getHeight()));//得到战机的高和宽width=my.getWidth()/4;heigth=my.getHeight();x=(display_w - my.getWidth()/4)/2;y=display_h-my.getHeight()-30;}private int index=0;private int num =0;@Overridepublic Bitmap getBitmap() {Bitmap bitmap = bitmaps.get(index);//控制切换四个飞机的频率if(num == 7){index++;if(index == bitmaps.size()){index=0;}num=0;}num++;return bitmap;}@Overridepublic int getX() {return x;}@Overridepublic int getY() {return y;}public void setY(int y){this.y=y;}public void setX(int x){this.x=x;}}//负责背景照片的处理private class BeijingImage implements GameImage{private Bitmap bg;private BeijingImage(Bitmap bg){this.bg=bg;newBitmap = Bitmap.createBitmap(display_w,display_h, Bitmap.Config.ARGB_8888);}private Bitmap newBitmap = null;private int height = 0;public Bitmap getBitmap(){Paint p = new Paint();Canvas canvas = new Canvas(newBitmap);canvas.drawBitmap(bg,new Rect(0,0,bg.getWidth(),bg.getHeight()),new Rect(0,height,display_w,display_h+height),p);canvas.drawBitmap(bg,new Rect(0,0,bg.getWidth(),bg.getHeight()),new Rect(0,-display_h+height,display_w,height),p);height++;if(height==display_h){height=0;}return newBitmap;}public int getX(){return 0;}public int getY(){return 0;}}private boolean state = false;private SurfaceHolder holder;//绘画中心public void run() {Paint p1 = new Paint();int diren_num=0;//
        try{while(true){Canvas newCanvas = new Canvas(erjihuancun);for(GameImage image:(List<GameImage>)gameImage.clone()){newCanvas.drawBitmap(image.getBitmap(),image.getX(),image.getY(),p1);}if(diren_num==150){diren_num=0;gameImage.add(new DijiImage(diren));}diren_num++;Canvas canvas = holder.lockCanvas();canvas.drawBitmap(erjihuancun,0,0,p1);holder.unlockCanvasAndPost(canvas);Thread.sleep(10);}}catch(Exception e){}}@Overridepublic void surfaceCreated(SurfaceHolder holder) {}@Overridepublic void surfaceDestroyed(SurfaceHolder holder) {state = false;}@Overridepublic void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {//得到屏幕的宽和高display_w=width;display_h=height;init();this.holder=holder;state = true;new Thread(this).start();}}
dafeijiGameView

 

 

游戏中添加子弹

 

 private class Zidan implements GameImage{Bitmap zidan;private FeijiImage feiji;private int x;private int y;public Zidan(FeijiImage feiji,Bitmap zidan){this.feiji=feiji;this.zidan=zidan;x=(feiji.getX()+feiji.getWidth()/2)-25;//居中位置y=feiji.getY()-zidan.getHeight();}public Bitmap getBitmap() {y-=19;if(y<=-10){zidans.remove(this);}return zidan;}@Overridepublic int getX() {return x;}@Overridepublic int getY() {return y;}}
zidan.class

 

  判断子弹出现飞机位置

        public Zidan(FeijiImage feiji,Bitmap zidan){this.feiji=feiji;this.zidan=zidan;x=(feiji.getX()+feiji.getWidth()/2)-25;//居中位置y=feiji.getY()-zidan.getHeight();}

  (-25是自己微调)

 

  子弹超出边界的时候释放子弹内存,减少手机开销

        public Bitmap getBitmap() {y-=19;if(y<=-10){zidans.remove(this);}return zidan;}

 

  不断的出现新的子弹

                if(selectfeiji!=null){if(zidan_num==10){zidans.add(new Zidan(selectfeiji,zidan));zidan_num=0;}zidan_num++;}

 

  便利所有的子弹

                for(GameImage image:(List<GameImage>)zidans.clone()){newCanvas.drawBitmap(image.getBitmap(),image.getX(),image.getY(),p1);}

 

转载于:https://www.cnblogs.com/1138720556Gary/p/9457052.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/367829.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

关于HTML5本地持久化存储的Web SQL、Local Storage、Cookies技术

在浏览器客户端记录一些信息&#xff0c;有三种常用的Web数据持久化存储的方式&#xff0c;分别是Web SQL、Local Storage、Cookies。Web SQL作为html5本地数据库&#xff0c;可通过一套API来操纵客户端的数据库&#xff08;关系数据库&#xff09;&#xff0c;下面是支持浏览器…

死锁

7.1 系统模型 定义&#xff1a;多个进程竞争一定数量的资源&#xff0c;某个进程申请资源&#xff0c;若此时该资源不可用&#xff0c;则进程进入等待状态。若所申请的资源被其他等待进程占用&#xff0c;则该等待进程可能再也不法改变其状态。 进程使用资源的顺序&#xff1a;…

mysql lepus_MySQL 监控软件lepus天兔

概述类别版本操作系统Centos 7.4数据库版本MySQL 5.6.49天兔版本lepus 3.7依赖软件1.MySQL 5.0及以上(必须,用来存储监控系统采集的数据)2.Apache 2.2及以上 (必须,WEB服务器运行服务器)3.PHP 5.3以上 (必须,提供WEB界面支持)4.Python2 (必须,推荐2.6及以上版本,执行数据采集和…

模式的秘密--工厂模式

工厂模式概念&#xff1a; 实例化对象&#xff0c;用工厂方法代替new操作工厂模式包括工厂方法模式和抽象工厂模式抽象工厂模式是工厂方法模式的扩展工厂模式的意图&#xff1a; 定义一个接口创建对象&#xff0c;但是让子类决定哪些类需要被实例化。工厂方法把实例化的工作推迟…

Html5移动开发之Localstorage(本地存储)

HTML5本地存储Localstorage自从Html5中出现了本地存储的&#xff08;LocalStorage)的概念后&#xff0c;很多人都会想这个东西和我们传统web开发中的Cookie有什么特别之处&#xff0c;当然笔者也是其中之一&#xff0c;也难怪&#xff0c;以前用惯了cookie对于新出现的事物总是…

java response 获得code_Java教程分享使用HttpClient抓取页面内容

Java教程分享使用HttpClient抓取页面内容&#xff0c;使用HttpClient工具来发送Http请求1.简介HttpClient 是 Apache Jakarta Common 下的子项目&#xff0c;用来提供高效的、最新的、功能丰富的支持 HTTP 协议的客户端编程工具包&#xff0c;并且它支持 HTTP 协议最新的版本和…

linux mysql 5.6.23_MySQL 5.6.23升级到MySQL 5.7.9

MySQL 5.6.23升级到MySQL 5.7.9MySQL 5.7.9新特性一、安全性1.1. 用户表 mysql.user 的 plugin字段不允许为空&#xff0c; 默认值是 mysql_native_password&#xff0c;而不是 mysql_old_password&#xff0c;不再支持旧密码格式;1.2. 增加密码过期机制&#xff0c;过期后需要…

2018-03-02

1、首先我得重新在git设置一下身份的名字和邮箱&#xff08;因为当初都忘了设置啥了&#xff0c;因为遇到坑了&#xff09;进入到需要提交的文件夹底下&#xff08;因为直接打开git Bash&#xff0c;在没有路径的情况下&#xff0c;根本没&#xff01;法&#xff01;改&#xf…

查看环境变量有无配置成功等命令操作

查看环境变量有无配置成功 &#xff1a;windowR cmd set&#xff08;回车&#xff09; 现在可以看到配置成功的环境变量NVM_HOME NVM_SYMLINK等环境变量 也可以单独查看某个变量有无配置成功,例如set NVM—HOME. 转载于:https://www.cnblogs.com/JavascriptAndHtml5/p/9469932…

WildFly 8.0.0.Alpha1的发布和一些历史

自从我们发布WildFly 8.0.0.Alpha1版本以来&#xff0c; 已经过去了大约2周。 该下载位于WildFly下载页面上 。 我敢肯定&#xff0c;你们中的许多人可能会想知道WildFly是什么&#xff0c;而其中一些知道它是什么的人可能不会知道已经发布了。 我将尝试回答其中一些问题&#…

POJ 1276 Cash Machine

很容易看出来是一个背包问题&#xff0c;开始把每一张钞票都跑了一遍01背包&#xff0c;直接TLE了。 其实就是多重背包模板题。 1 //#include <bits/stdc.h>2 #include <iostream>3 #include <utility>4 #include <vector>5 #include <cstring>6…

导出mysql excel数据字典_mysql导出 Excel数据字典(全)

解决问题(有mysql数据库数据表想要将表导入到PowerDesigner 或导出Excel数据字典)一、下载工具1、工具PowerDesigner 百度自行下载安装2、mysql-connector-odbc 下载链接: https://pan.baidu.com/s/1cjb73f3GvkkMFAzZKi85xA 提取码: u5ih二、mysql数据库数据表想要将表导入到Po…

斐波那契数列算法小结

关于求解斐波那契数列&#xff0c;这是一道比较经典的题目&#xff0c;本文主要是对斐波那契数列求解方法的小结。 首先&#xff0c;定义Fibonacci数列如下&#xff1a; 方法1&#xff1a; 利用递归求解&#xff0c;这是最容易写出的算法&#xff0c;代码如下&#xff1a; #inc…

mysql yintint类型_MySQL服务器2 被嫌弃的胖子

1.sql的基本语法对数据库create database db1;  创建数据库对表&#xff1a;create database t1(id int,name char(10));  创建表show create table t1;  查看创建的t1表show tables;  查看所有的表desc t1;  查看表的详细结构对数据&#xff1a;insert into t1(id,n…

Html5表单元素-搜索框和上传文件框

1、search - 搜索框element/form/input/search.html<!doctype html><html><head> <title>search</title></head><body> <!-- search - 搜索框&#xff0c;文本框形式 --> <input type"search"…

使用AspectJ审计Spring MVC Webapp。 第2部分

现在&#xff0c;如果您有兴趣创建一个以Aspectj的Aspect和Before批注的形式使用面向方面编程&#xff08;AOP&#xff09;的Spring MVC Webapp来审核用户对屏幕的访问&#xff0c;那么这是您想要阅读的博客。 正如我在上一个博客中所说的那样&#xff0c;审核用户对屏幕的访问…

服装店管理系统打造门店拓客、促活、存留营销方案

打造门店拓客、促活和存留营销方案对于服装店的管理系统来说是非常重要的。以下是一些可行的方案&#xff1a; 1. 会员管理系统&#xff1a;引入会员管理功能&#xff0c;建立会员档案&#xff0c;跟踪会员消费记录和偏好。通过会员系统&#xff0c;可以实施积分制度、生日礼品…

mysql添加映射模块_iis7.5中让html与shtml一样支持include功能(添加模块映射)

刚开始弄得时候&#xff0c;发现了很多错误&#xff0c;其实很简单&#xff0c;参考shtm原来的设置就可以了前提条件&#xff1a;ServerSideIncludeModule的安装&#xff1a;在安装iis的时候选择上该服务(“在服务端包含文件”&#xff0c;选项)即可&#xff0c;如下&#xff1…

文件上传控件bootstrap-fileinput的使用

一、准备1、插件下载地址&#xff1a;https://github.com/kartik-v/bootstrap-fileinput/ 下载后的压缩包解压文件夹内容如下&#xff1a; js&#xff1a;插件核心js代码&#xff0c;引用fileinput.min.js/fileinput.js即可&#xff0c;默认插件语言为英文&#xff0c;如需要中…

在JPA 2.1中使用@Convert正确完成映射枚举

如果您曾经在JPA中使用过Java枚举&#xff0c;那么您肯定会意识到它们的局限性和陷阱。 使用enum作为Entity的属性通常是一个很好的选择&#xff0c;但是2.1之前的JPA不能很好地处理它们。 它给了您2 1个选择&#xff1a; 托肖夫达林 Enumerated(EnumType.ORDINAL) &#xf…