日期:2014-05-20  浏览次数:20635 次

关于Midp1.0画地图的问题,请帮我看看这个手机上画地图的方法错在哪里呢??
请问1.0用setclip铺地图应该怎么铺啊?
这个是我自己写的但是铺出来的不对的,我知道应该是我setclip跟drawImage里的参数没写对,但不知道应该怎么填,,请问应该怎么填啊,请帮帮忙吧!谢谢

public class Map extends Canvas 
{
int width = getWidth(); //屏幕的宽
int height = getHeight();//屏幕的高

int mapRow = 30;//地图总行数
int mapCol = 30;//地图总列数

int w = 16;//每个格子宽
int h = 16;//每个格子高

int sw = getWidth()/w;//屏幕总行数
int sh = getHeight()/h;//屏幕总列数

int map_x = 0;//地图的x初始坐标
int map_y = 0;//地图的y初始坐标

Image gamemap = null;

int gamemap_map0[][] = 
{
  { 4, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 2, 3, 2, 3, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 4 },
  { 9, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 7, 8, 7, 8, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 9 },
  { 14, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 12, 13, 12, 13, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 14 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 22, 23, 23, 24, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 4, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 4, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 9, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 9, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 14, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 14, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },
  { 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 },