


下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
【移動(dòng)應(yīng)用開發(fā)技術(shù)】Android中怎么實(shí)現(xiàn)底圖局部加載移動(dòng)
今天就跟大家聊聊有關(guān)Android中怎么實(shí)現(xiàn)底圖局部加載移動(dòng),可能很多人都不太了解,為了讓大家更加了解,在下給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。具體如下: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,前提,你圖片確實(shí)比屏幕大,如果不比屏幕大,下面注釋行修改一下即可。
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);
}
}
}調(diào)用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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權(quán)】 IEC TS 61850-6-3:2025 EN Communication networks and systems for power utility automation - Part 6-3: Format of machine-processable rules for validation of IEC 61850 XML-base
- 海淀區(qū)初中二模數(shù)學(xué)試卷
- 醫(yī)院資產(chǎn)管理課件
- 中國(guó)異葉天南星行業(yè)市場(chǎng)全景監(jiān)測(cè)及投資策略研究報(bào)告
- 2025年圍棋棋子市場(chǎng)分析報(bào)告
- 2025年種桑養(yǎng)蠶項(xiàng)目可行性研究報(bào)告
- 2024-2030年中國(guó)番茄沙司行業(yè)市場(chǎng)深度分析及投資戰(zhàn)略規(guī)劃建議報(bào)告
- 2025年中國(guó)機(jī)動(dòng)車行業(yè)市場(chǎng)全景調(diào)研及投資規(guī)劃建議報(bào)告
- 2025年中國(guó)功率計(jì)行業(yè)市場(chǎng)深度分析及投資戰(zhàn)略研究報(bào)告
- 健康的重要性
- 2025灌南縣國(guó)企招聘考試題目及答案
- 采購(gòu)螺絲合同協(xié)議
- GB/T 45481-2025硅橡膠混煉膠醫(yī)療導(dǎo)管用
- 公司電子屏管理制度
- 采購(gòu)詢價(jià)制度
- 2025年上海高考英語復(fù)習(xí)必背考綱詞匯手冊(cè)默寫
- 肩袖修補(bǔ)術(shù)護(hù)理
- 月子中心員工手冊(cè)管理制度
- DB37-T 1933-2022 氯堿安全生產(chǎn)技術(shù)規(guī)范
- 2025中考數(shù)學(xué)專項(xiàng)復(fù)習(xí):最值問題之瓜豆原理模型(含答案)
- 2025年浙江寧波北侖熱力有限公司招聘筆試參考題庫(kù)含答案解析
評(píng)論
0/150
提交評(píng)論