付费下载
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
【移动应用开发技术】Android中怎么实现底图局部加载移动
今天就跟大家聊聊有关Android中怎么实现底图局部加载移动,可能很多人都不太了解,为了让大家更加了解,在下给大家总结了以下内容,希望大家根据这篇文章可以有所收获。具体如下:public
class
MapMgr
{
public
static
MapMgr
mapMgr
=
null;
private
int
map_num
=
28;
private
int
b_x
=
0;
private
int
b_y
=
0;
private
int
width
=
0;
private
int
height
=
0;
private
Bitmap
bmpView
=
null;
//create
by
danielinbiti,前提,你图片确实比屏幕大,如果不比屏幕大,下面注释行修改一下即可。
public
static
void
init(int
width,int
height){
if(mapMgr==null){
mapMgr
=
new
MapMgr(width,height);
}
}
public
static
MapMgr
getInstance(){
return
mapMgr;
}
public
MapMgr(int
width,int
height){
this.width
=
width;
this.height
=
height;
Bitmap
bmp
=
PicMgr.getInstance().getBackGroundBitmap();
b_x
=
(bmp.getWidth()-width)/2;//保证图片比屏幕大
b_y
=
(bmp.getHeight()-height)/2;
bmpView
=
Bitmap.createBitmap(bmp,
b_x,
b_y,
width,
height);
}
public
void
logic(){
}
public
void
mapDown(){
Bitmap
bmp
=
PicMgr.getInstance().getBackGroundBitmap();
if(b_y+height<bmp.getHeight()){
b_y
=
b_y
+
bmp.getHeight()/map_num;
if(b_y+height>bmp.getHeight()){
b_y
=
bmp.getHeight()
-
height;
}
}
bmpView
=
Bitmap.createBitmap(bmp,
b_x,
b_y,
width,
height);
}
public
void
mapUp(){
Bitmap
bmp
=
PicMgr.getInstance().getBackGroundBitmap();
if(b_y>0){
b_y
=
b_y
-
bmp.getHeight()/map_num;
if(b_y<0){
b_y
=
0;
}
}
bmpView
=
Bitmap.createBitmap(bmp,
b_x,
b_y,
width,
height);
}
public
void
mapLeft(){
Bitmap
bmp
=
PicMgr.getInstance().getBackGroundBitmap();
if(b_x>0){
b_x
=
b_x
-
bmp.getWidth()/map_num;
if(b_x<0){
b_x
=
0;
}
}
bmpView
=
Bitmap.createBitmap(bmp,
b_x,
b_y,
width,
height);
}
public
void
mapRight(){
Bitmap
bmp
=
PicMgr.getInstance().getBackGroundBitmap();
if(b_x+width<bmp.getWidth()){
b_x
=
b_x
+
bmp.getWidth()/map_num;
if(b_x+width>bmp.getWidth()){
b_x
=
bmp.getHeight()
-
width;
}
}
bmpView
=
Bitmap.createBitmap(bmp,
b_x,
b_y,
width,
height);
}
public
void
draw(Canvas
canvas){
Paint
paint
=
new
Paint();
if(bmpView!=null){
canvas.drawBitmap(bmpView,0,
0,
paint);
}
}
}调用public
void
onKeyDownDeal(int
keyCode){
if(keyCode==KeyEvent.KEYCODE_DPAD_UP){
MapMgr.getInstance().mapUp();
}else
if(keyCode==KeyEvent.KEYCODE_DPAD_DOWN){
MapMgr.getInstance().mapDown();
}else
if(keyCode==KeyEvent.KEYCODE_DPAD_LEFT){
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 福建省厦门市英才学校2026届生物高一下期末联考模拟试题含解析
- 2026届广东省佛山市南海区高一数学第二学期期末预测试题含解析
- 2026届甘肃省庆阳市镇原县镇原中学高一下数学期末质量检测试题含解析
- 2025年日照小学直播教师笔试真题及答案
- 2025年阿拉尔事业编考试真题及答案
- 2025年港城市场营销面试题库及答案
- 2025年伊春嘉荫县事业单位考试及答案
- 2025年淄矿集团定向生笔试及答案
- 2025年泸溪县招教考试备考题库带答案解析(夺冠)
- 2024年理塘县招教考试备考题库附答案解析
- 学校中层管理岗位职责及分工明细(2026年版)
- 莆田春节习俗介绍
- 江苏省南京市2025届中考化学试卷(含答案)
- 飞行固模课件
- 2025年中考英语真题完全解读(重庆卷)
- 学前教育创意短片
- 2026年短视频合作合同
- 建筑临时设施设计方案
- 污水厂春节复工安全培训课件
- 电场防寒防冻知识培训课件
- 审贷分离管理办法
评论
0/150
提交评论