package com.example.a11918.myapplication;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
/**
* Created by 11918 on 2017/5/25.
*/
/**
* 地图类
*/
public class GameBackground {
private Bitmap bmpBg1;
private Bitmap bmpBg2;
private int speed = 5;
private int y1, y2;
public GameBackground(Bitmap bmpBg) {
this.bmpBg1 = bmpBg;
this.bmpBg2 = bmpBg;
y1 = Math.abs(GameSurfaceView.screenHight - bmpBg1.getHeight());
y2 = y1 - bmpBg1.getHeight();
}
/**
* 画出地图
* @param canvas
* @param paint
*/
public void drawBK(Canvas canvas, Paint paint) {
canvas.drawBitmap(bmpBg1, 0, y1, paint);
canvas.drawBitmap(bmpBg1, 0, y2, paint);
}
/**
* 让地图不停重复滚动
*/
public void logic(){
y1 += speed;
y2 += speed;
if (y1>GameSurfaceView.screenHight){
y1 = y2 - bmpBg2.getHeight();
}
if (y2>GameSurfaceView.screenHight){
y2 = y1 - bmpBg2.getHeight();
}
}
}
初学Android之飞机大战(二)——地图
最新推荐文章于 2021-07-20 10:56:42 发布