Public class mapmgr {public static 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 BMP view = NULL; // create by danielinbiti, if your image is indeed larger than the screen, modify the comment below. 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; // ensure that the image is larger than the screen's B _y = (BMP. getheight ()-height)/2; BMP view = bitmap. createbitmap (B MP, 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 ;}} BMP view = bitmap. createbitmap (BMP, B _x, B _y, width, height);} public void mapup () {bitmap BMP = picmgr. getinstance (). getbackgro Undbitmap (); If (B _y> 0) {B _y = B _y-BMP. getheight ()/map_num; If (B _y <0) {B _y = 0 ;}} BMP view = 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 ;}} BMP view = bitmap. createbitmap (BMP, B _x, B _y, width, height);} public void mapright () {bitmap BMP = P Icmgr. 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 ;}} BMP view = bitmap. createbitmap (BMP, B _x, B _y, width, height);} public void draw (canvas) {paint = new paint (); If (BMP view! = NULL) {canvas. drawbitmap (BMP view, 0, 0, paint );}}}
Call
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) {mapmgr. getinstance (). mapleft ();} else if (keycode = keyevent. keycode_dpad_right) {mapmgr. getinstance (). mapright ();}}
Then, use the thread to call draw for Refresh.
For touch movement, the coordinate calculation method is different, and others are similar. In addition, it can be expanded to GIS, and content can be locally loaded based on small image pasting.