當前位置: 首頁>>代碼示例>>Java>>正文


Java Rectangle.contains方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.math.Rectangle.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle.contains方法的具體用法?Java Rectangle.contains怎麽用?Java Rectangle.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.math.Rectangle的用法示例。


在下文中一共展示了Rectangle.contains方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: pickPiece

import com.badlogic.gdx.math.Rectangle; //導入方法依賴的package包/類
public boolean pickPiece() {
    Vector2 mouse = new Vector2(
            Gdx.input.getX(),
            Gdx.graphics.getHeight() - Gdx.input.getY()); // Y axis is inverted

    final float perPieceWidth = area.width / count;
    for (int i = 0; i < count; ++i) {
        if (pieces[i] != null) {
            Rectangle maxPieceArea = new Rectangle(
                    area.x + i * perPieceWidth, area.y, perPieceWidth, area.height);

            if (maxPieceArea.contains(mouse)) {
                heldPiece = i;
                return true;
            }
        }
    }

    heldPiece = -1;
    return false;
}
 
開發者ID:LonamiWebs,項目名稱:Klooni1010,代碼行數:22,代碼來源:PieceHolder.java

示例2: query

import com.badlogic.gdx.math.Rectangle; //導入方法依賴的package包/類
/**�߿ռ�����*/
		public void query(Rectangle rect, Array<IQuadTreeObject> ret) {
//			System.out.println("query side begin ---------- ");
//			System.out.println("rect = " + rect + " type = " + type + "min, max, centerX, centerY = " 
//					+ min + " " + max + " " + centerX + " " + centerY);
			boolean flag = false;
			switch(type) {
			case 0:
				if(rect.contains(min, centerY)) {
					flag = true;
				}
				break;
			case 1:
				if(rect.contains(centerX, min)) {
					flag = true;
				}
				break;
			case 2:
				if(rect.contains(max, centerY)) {
					flag = true;
				}
				break;
			case 3:
				if(rect.contains(centerX, max)) {
					flag = true;
				}
				break;
			}
			
			if(!flag) {return;}
			
//			System.out.println("query side success ---------- ");
			if(children != null) {
//				System.out.println("query child side begin ---------- ");
				children[0].query(rect, ret);
				children[1].query(rect, ret);
//				System.out.println("query child side end ---------- ");
			}
			
			for(int i = objs.size - 1; i >= 0; --i) {
				ret.add(objs.get(i));
			}
//			System.out.println(this + " ret = " + objs.size);
		}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:45,代碼來源:QuadTreeV2.java

示例3: query

import com.badlogic.gdx.math.Rectangle; //導入方法依賴的package包/類
/**�߿ռ�����*/
		public void query(Rectangle rect, Array<IQuadTreeObject> ret) {
//			System.out.println("query side begin ---------- ");
//			System.out.println("rect = " + rect + " type = " + type + "min, max, centerX, centerY = " 
//					+ min + " " + max + " " + centerX + " " + centerY);
			boolean flag = false;
			switch(type) {
			case 0:
				if(rect.contains(min, centerY)) {
					flag = true;
				}
				break;
			case 1:
				if(rect.contains(centerX, min)) {
					flag = true;
				}
				break;
			case 2:
				if(rect.contains(max, centerY)) {
					flag = true;
				}
				break;
			case 3:
				if(rect.contains(centerX, max)) {
					flag = true;
				}
				break;
			}
			
			if(!flag) {return;}
			
//			System.out.println("query side success ---------- ");
			if(children != null) {
//				System.out.println("query child side begin ---------- ");
				children[0].query(rect, ret);
				children[1].query(rect, ret);
//				System.out.println("query child side end ---------- ");
			}
			
			ret.addAll(objs); 
//			System.out.println(this + " ret = " + objs.size);
		}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:43,代碼來源:QuadTree.java


注:本文中的com.badlogic.gdx.math.Rectangle.contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。