当前位置: 首页>>代码示例>>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;未经允许,请勿转载。