Good night you two.
@groengeel Just hope I didn't figure that out first then.
/** * Check whether this object intersects with another given object. * * @return True if the object's intersect, false otherwise. */ protected boolean intersects(Actor actor){ int ax = getX() - getImage().getWidth()/2; int ay = getY() - getImage().getHeight()/2; List<String> ac = new ArrayList(); for(int ix=0; ix<getImage().getWidth(); ix++) { int dx = ax+ix; for(int iy=0; iy<getImage().getHeight(); iy++) { int dy = ay+iy; if (actor.isContain(dx,dy)) { return true; } } } return false; }
boolean isContain(float px, float py){ float distance = distanceTo(px, py); double degrees = degreesTo(px, py); float dx = distance * (float)Math.cos(Math.toRadians(degrees - (double)rotation)); float dy = distance * (float)Math.sin(Math.toRadians(degrees - (double)rotation)); RectF rect = new RectF(-getWidth() / 2, -getHeight() / 2, getWidth() / 2, getHeight() / 2); return rect.contains(dx, dy); } boolean isContain(PointF point){ return isContain(point.x, point.y); }