public void draw (Batch batch, float parentAlpha) { selectBox.localToStageCoordinates(temp.set(0, 0)); if (!temp.equals(screenPosition)) hide(); super.draw(batch, parentAlpha); }
public void draw (Batch batch, float parentAlpha) { selectBox.localToStageCoordinates(temp.set(0, 0)); if (!temp.equals(screenPosition)) hide(); super.draw(batch, parentAlpha); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Triangle2 triangle = (Triangle2) o; if (a != null ? !a.equals(triangle.a) : triangle.a != null) return false; if (b != null ? !b.equals(triangle.b) : triangle.b != null) return false; return c != null ? c.equals(triangle.c) : triangle.c == null; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Triangle2 triangle = (Triangle2) o; if (a != null ? !a.equals(triangle.a) : triangle.a != null) return false; if (b != null ? !b.equals(triangle.b) : triangle.b != null) return false; return c != null ? c.equals(triangle.c) : triangle.c == null; }
public static Direction getDirectionFor(float x, float y) { final Vector2 cmp = new Vector2((x < 0) ? -1 : (x == 0) ? 0 : 1, (y < 0) ? -1 : (x == 0) ? 0 : 1); for (Direction dir : values) { if (dir.vector.equals(cmp)) { return dir; } } return NORTH; }
public void draw (Batch batch, float parentAlpha) { selectBox.localToStageCoordinates(temp.set(0, 0)); if (!temp.equals(screenPosition)) hide(); super.draw(batch, parentAlpha); }
public void draw(Batch batch, float parentAlpha) { selectBox.localToStageCoordinates(temp.set(0, 0)); if (!temp.equals(screenPosition)) hide(); super.draw(batch, parentAlpha); }
public static Array<Vector2> MergeIdenticalPoints(Array<Vector2> vertices) { Array<Vector2> results = new Array<Vector2>(); for (int i = 0; i < vertices.size; i++) { Vector2 vOriginal = vertices.get(i); boolean alreadyExists = false; for (int j = 0; j < results.size; j++) { Vector2 v = results.get(j); if (vOriginal.equals(v)) { alreadyExists = true; break; } } if (!alreadyExists) results.add(vertices.get(i)); } return results; }
public static Array<Vector2> MergeIdenticalPoints(Array<Vector2> vertices) { Array<Vector2> results = new Array<Vector2>(); for (int i = 0; i < vertices.size; i++) { Vector2 vOriginal = vertices.get(i); boolean alreadyExists = false; for (int j = 0; j < results.size; j++) { Vector2 v = results.get(j); if (vOriginal.equals(v)) { alreadyExists = true; break; } } if (!alreadyExists) results.add(vertices.get(i)); } return results; }
public void updateGameLoop(float deltaTime) { Vector2 current = body.getPosition(); Vector2 target = new Vector2(100, 100); if (!current.equals(target)) { float speed = 20f; Vector2 direction = target.sub(current); float distanceToTarget = direction.len(); float travelDistance = speed * deltaTime; // the target is very close, so we set the position to the target directly if (distanceToTarget <= travelDistance) { body.setTransform(target, body.getAngle()); } else { direction.nor(); // move a bit in the target direction body.setTransform(current.add(direction.mul(travelDistance)), body.getAngle()); } } }
public static void simplify(Array<Vector2> points, float sqTolerance, Array<Vector2> out) { int len = points.size; Vector2 point = new Vector2(); Vector2 prevPoint = points.get(0); out.clear(); out.add(prevPoint); for (int i = 1; i < len; i++) { point = points.get(i); if (distSq(point, prevPoint) > sqTolerance) { out.add(point); prevPoint = point; } } if (!prevPoint.equals(point)) { out.add(point); } }