This is what I'm trying to accomplish. I want an item to show up on the screen at the last position the mouse had clicked. Currently it sort of works, but every time I click elsewhere the said item moves there as well. I just want it to be static.
Here's some code:
global variables px and py. Used to hold mouse clicks:
private int px = 250; // initial coordinates
private int py = 250;
mouse clicks feed global px and py:
private void testPress(int x, int y) {
if (!isPaused && !gameOver) {
// do something..
px = x;
py = y;
girlP.setDestination((px-(girlP.getImage().getWidth(this)/2)),
(py-(girlP.getImage().getHeight(this)/2)));
//System.out.println(px + ", " + py);
}
}
There px and py are constantly updated with new values. What I want is a way to only hold the last mouse click