[摘要]Graphics.LEFT);//画背景 MyMap.draw_map(g);//按照地图内容画图 if ( this.selected ) g.s...
Graphics.LEFT);//画背景
MyMap.draw_map(g);//按照地图内容画图
if ( this.selected )
g.setColor(0,255,0);//如果被选中,改用绿色画出被选中的区域
g.drawRect(this.SelectArea[0] * Images.UNIT + Images.LEFT,
this.SelectArea[1] * Images.UNIT + Images.TOP,
this.SelectArea[2] * Images.UNIT,
this.SelectArea[3] * Images.UNIT);//画出选择区域,
<A href="file://如">file://如</A>果被选中,就用绿色
<A href="file://否">file://否</A>则,使用黑色
g.setColor(255,255,255);//恢复画笔颜色
if (this.selected) {//已经选中了要移动的区域
g.setColor(255, 0, 255);//改用红色
g.drawRect(this.MoveArea[0] * Images.UNIT + Images.LEFT,
this.MoveArea[1] * Images.UNIT + Images.TOP,
this.MoveArea[2] * Images.UNIT,
this.MoveArea[3] * Images.UNIT);//画出要移动到的区域
g.setColor(255, 255, 255);//恢复画笔颜色
}
}catch (Exception ex) {
}
System.out.println(Runtime.getRuntime().freeMemory());
System.out.println(Runtime.getRuntime().totalMemory());
}
private void setRange() {
//设置移动后能够选中的区域
//调整当前光标位置到地图的主位置,即记录人物信息的位置
if (this.MyMap.Grid[this.loc[1]][this.loc[0]] == Images.DLEFT) {
this.loc[0] -= 1;//向左调
}else if (this.MyMap.Grid[this.loc[1]][this.loc[0]] == Images.DUP) {
this.loc[1] -= 1;//向上调
}else if (this.MyMap.Grid[this.loc[1]][this.loc[0]] == Images.DLEFTUP) {
this.loc[0] -= 1;//向左调
this.loc[1] -= 1;//向上调
}
this.SelectArea[0] = this.loc[0];//设置光标的水平位置
this.SelectArea[1] = this.loc[1];//设置光标的竖直位置
//设置光标的宽度
if (this.loc[0] + 1 < Images.WIDTH) {
this.SelectArea[2] = this.MyMap.Grid[this.loc[1]][this.loc[0] + 1] != (byte) '1' ?
1 : 2;
}else {
this.SelectArea[2] = 1;
}
//设置光标的高度
if (this.loc[1] + 1 < Images.HEIGHT) {
this.SelectArea[3] = this.MyMap.Grid[this.loc[1] + 1][this.loc[0]] != (byte) '2' ?
1 : 2;
}else {
this.SelectArea[3] = 1;
}
}
private boolean setMoveRange() {
//设置要移动到的区域,能够移动返回true,否则返回false
for (int i = 0; i < this.SelectArea[2]; i++) {
for (int j = 0; j < this.SelectArea[3]; j++) {
if (this.loc[1] + j >= Images.HEIGHT
关键词:j2me游戏开发案例讲解