I'm using Point2D to specify co-ordinates in the game window.
This is working fine, I tried using Point2D.distance using my Point2D variables and it says that I'm entering a double.
I almost know that I am not, just before Point2D.distance is called I use line2D.setLine, using the point arguments, which works fine.
Here's my code, I even cast the mouseInfo instance into a point2D, but to no avail, please have a look at my code and tell me where I'm going wrong:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| public class Boomerang extends Sprite { private static double DURATION = 0.5; private int period; private BricksManager brickMan; private Point2D[] boomPath; private int speed; protected int locx, locy; private Boolean isVisible; private JumperSprite rat; private Line2D path; private Point2D startPoint; private Point2D nodeLength;
public Boomerang (int x, int y, BricksManager bm, ImagesLoader imsLd, int p, String name) { ...... }
public void fire(){ int midx = rat.getWidth()/2; int midy = rat.getHeight()/2; startPoint.setLocation((rat.getXPosn() + midx), (rat.getYPosn() - midy)); PointerInfo MousePosn = MouseInfo.getPointerInfo(); boomPath[1] = (Point2D) MousePosn.getLocation(); path.setLine(startPoint, boomPath[1]); nodeLength = startPoint.distance(boomPath[1]); |
I've tried using different arguments on startPoint and even taking it out and using this:
1
| nodeLength = Point2D.distance(startPoint.getX(), startPoint.getY(), boomPath[1].getX(), boomPath[1].getY()); |
It again tells me I'm using doubles, I think that boomPath[1] is the culprit, but the api says getLocation() returns a point?
Please help!