?? mousesprite.java
字號:
package com.tianxia.qipai.model.game.gobang;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
public class MouseSprite extends Sprite {
private int rectflag; //當前區域標志 0:chatrect 1: qipanrect 2: operaterect 3: inforect
private int firX; //當前區域的四個坐標
private int firY;
private int endX;
private int endY;
private int width; //當前區域內指針每次移動的寬度和高度
private int height;
private int orignX; //當前區域指針的初始位置
private int orignY;
private int xnum; //當前區域指針橫向和縱向可移動的最多格數
private int ynum;
private int currx; //當前指針的位置 單元格為單位
private int curry;
private int xposition,yposition; //指針的當前坐標位置
private boolean rightrect; //各個方向是否有相鄰的區域
private boolean leftrect;
private boolean uprect;
private boolean downrect;
private MouseRect chatrect,operaterect,inforect,qipanrect; //聊天區域,菜單區域,用戶信息區域,棋盤區域
public MouseSprite(Image arg0,int tilewidth,int tileheight) {
super(arg0,tilewidth,tileheight);
// TODO 自動生成構造函數存根
}
public void init(MouseRect chatrect,MouseRect operaterect,
MouseRect inforect,MouseRect qipanrect){
this.chatrect = new MouseRect(chatrect);
this.operaterect = new MouseRect(operaterect);
this.inforect = new MouseRect(inforect);
this.qipanrect = new MouseRect(qipanrect);
this.setCurrRect(operaterect);
this.setDisplay();
}
public void setDisplay(){
if(rectflag == 1){
this.setVisible(false);
}
else{
this.setVisible(true);
}
xposition = orignX + currx*width;
yposition = orignY + curry*height;
this.setPosition(xposition,yposition);
}
public void setCurrRect(MouseRect rect){ //設置當前指針進入的區域
this.firX = rect.firX;
this.firY = rect.firY;
this.endX = rect.endX;
this.endY = rect.endY;
this.width = rect.width;
this.height = rect.height;
this.orignX = rect.orignX;
this.orignY = rect.orignY;
this.xnum = rect.xnum;
this.ynum = rect.ynum;
this.rightrect = rect.rightrect;
this.leftrect = rect.leftrect;
this.uprect = rect.uprect;
this.downrect = rect.downrect;
this.rectflag = rect.rectflag;
currx = 0;
curry = 0;
}
public int getRectFlag(){
return this.rectflag;
}
public int getCurry(){
return this.curry;
}
public int getCurrx(){
return this.currx;
}
public void RectConvert(){ //區域切換
switch(rectflag){
case 0:
setCurrRect(qipanrect);
this.setVisible(false);
break;
case 1:
setCurrRect(operaterect);
this.setVisible(true);
break;
case 2:
setCurrRect(inforect);
break;
case 3:
setCurrRect(chatrect);
break;
default:
break;
}
setDisplay();
}
public void NextPosition(int point){
switch(point){
case 0: //向上
if(curry==0){ //已經是最頂層
if( uprect ){ //
switch(rectflag){
case 0:
setCurrRect(operaterect);
break;
case 1:
case 3:
setCurrRect(chatrect);
break;
case 2:
setCurrRect(qipanrect);
break;
default:
break;
}
}
}
else{
curry = curry - 1;
}
break;
case 1: //向下
if(curry==ynum){ //已經是最下方
if( downrect ){ //
switch(rectflag){
case 0:
setCurrRect(inforect);
break;
case 1:
setCurrRect(operaterect);
break;
case 2:
setCurrRect(chatrect);
break;
case 3:
break;
default:
break;
}
}
}
else{
curry = curry + 1;
}
break;
case 2: //向左
if(currx==0){ //已經是最左側
if( leftrect ){ //
switch(rectflag){
case 0:
case 1:
setCurrRect(inforect);
break;
case 2:
setCurrRect(inforect);
curry = 1;
break;
case 3:
if(curry == 1){
setCurrRect(operaterect);
}
// else
// setCurrRect(operaterect);
break;
default:
break;
}
}
}
else{
currx = currx - 1;
}
break;
case 3: //向右
if(currx==xnum){ //已經是最右側
switch(rectflag){
case 1:
setCurrRect(inforect);
break;
case 2:
setCurrRect(inforect);
curry = 1;
break;
case 3:
if(yposition < chatrect.endY)
setCurrRect(chatrect);
else if(yposition > qipanrect.endY)
setCurrRect(operaterect);
else
setCurrRect(qipanrect);
this.setVisible(false);
break;
default:
break;
}
}
else{
currx = currx + 1;
}
break;
default:
break;
}
setDisplay();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -