当前位置: 首页>>代码示例>>Java>>正文


Java MathUtils.isEqual方法代码示例

本文整理汇总了Java中com.badlogic.gdx.math.MathUtils.isEqual方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.isEqual方法的具体用法?Java MathUtils.isEqual怎么用?Java MathUtils.isEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.math.MathUtils的用法示例。


在下文中一共展示了MathUtils.isEqual方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onUpdate

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
@Override
public void onUpdate(float deltaTime)
{
    if (!MathUtils.isZero(hitTimer))
    {
        hitTimer -= deltaTime;

        if (hitTimer <= 0f)
            hitTimer = 0f;
    }

    if (attackTimer > 0f)
        attackTimer -= deltaTime;

    if (handler.canAttack())
    {
        if (attackTimer <= 0f)
        {
            attackTimer = 1.6f;

            handler.attack(3);
        }
    }

    bodyPosition = body.getPosition();

    if (body.getLinearVelocity().sub(direction).len2() > 1 || (MathUtils.isEqual(oldPosition.x, bodyPosition.x) && MathUtils.isEqual(oldPosition.y, bodyPosition.y)))
    {
        direction.set(MathUtils.random(-1f, 1f), MathUtils.random(-1f, 1f));
        direction.scl(4f);
    }

    oldPosition = bodyPosition;

    body.applyForceToCenter(direction, true);
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:37,代码来源:Crab.java

示例2: checkCollisions

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
/** Check for collisions between two colliders */
private boolean checkCollisions(Collider a, Collider b){

	// Ignore collisions between objects with infinite mass
	if(MathUtils.isEqual(a.im, 0) && MathUtils.isEqual(b.im, 0)){
		return false;

	}else if((filter == null || filter.collide(a, b)) && a.isOverlapping(b)){

		if(listener != null){
			listener.onContact(a, b);
			listener.onContact(b, a);
		}

		//don't add a contact for triggers
		if(a.trigger || b.trigger){
			return true;
		}else{
			//Get a manifold from the pool and add it
			Manifold c = Pools.obtain(Manifold.class).set(a, b);
			if(c.solve()){
				contacts.add(c);
				return true;
			}
		}
	}

	return false;
}
 
开发者ID:Anuken,项目名称:GDX-AABB,代码行数:30,代码来源:CollisionEngine.java

示例3: onLine

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
/**Returns whether a point is on a line.*/
private static boolean onLine(Vector2 vector, float x1, float y1, float x2, float y2){
	return MathUtils.isEqual(vector.dst(x1, y1) + vector.dst(x2, y2), Vector2.dst(x1, y1, x2, y2), 0.01f);
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:5,代码来源:Pathfind.java

示例4: solve

import com.badlogic.gdx.math.MathUtils; //导入方法依赖的package包/类
/**
     * Solve the SAT for two AABBs
     */
public boolean solve(){

       // Vector from A to B
       float nx = a.x - b.x,
           ny = a.y - b.y;

       // Calculate half extends along x axis
       float aex = (a.max.x - a.min.x) / 2,
           bex = (b.max.x - b.min.x) / 2;

       // Overlap on x axis
       float xoverlap = aex + bex - Math.abs(nx);
       if (xoverlap > 0) {

           // Calculate half extends along y axis
           float aey = (a.max.y - a.min.y) / 2,
               bey = (b.max.y - b.min.y) / 2;

           // Overlap on x axis
           float yoverlap = aey + bey - Math.abs(ny);
           if (!MathUtils.isEqual(yoverlap, 0)) {

               // Find out which axis is the axis of least penetration
               if (xoverlap < yoverlap) {

                   // Point towards B knowing that n points from A to B
                   normal.x = nx < 0 ? 1 : -1;
                   normal.y = 0;
                   penetration = xoverlap;
                   return true;

               } else {

                   // Point towards B knowing that n points from A to B
                   normal.x = 0;
                   normal.y = ny < 0 ? 1 : -1;
                   penetration = yoverlap;
                   return true;

               }

           }

       }

       return false;

   }
 
开发者ID:Anuken,项目名称:GDX-AABB,代码行数:52,代码来源:Manifold.java


注:本文中的com.badlogic.gdx.math.MathUtils.isEqual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。