⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mousesprite.java

📁 java程序五子棋源代码。 java程序五子棋源代码。
💻 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 + -