Boy this problem is killing me.
danpost, thanks again, your last solution has the program moving without stopping, but I've now encountered yet another new problem.
And this is a request to anyone who might know a solution. :-/
The cursor object is transparent, the map moves underneath the cursor. Think of the cursor as an anchor for the eye. It's made to look like the cursor is moving, when in reality the map is moving underneath the cursor.
Here's the problem: In order for the map to work, the compiler must check the red level of a certain pixel at (16, 11) in each tile that the map is constructed with.
My plan was to use the cursor as the "anchor point" to determine where on the map to detect the red pixel. So what I'm trying to do is get the program to use the cursor's location, but detect the color of the pixel that is UNDERNEATH it.
So far, so good. But the program is now aiming at the cursor itself instead of the image underneath it, so the red value returned is always 0.
It's a shame we can't post pictures here, it would make things easier to see if I could screenshot it.
Anyway, here is the pertinent code (Scroller is the superclass, WorldMap and Cursor are underneath it):
From Scroller:
It calls the redCheck method inside of WorldMap..
From WorldMap:
I get a reference to the cursor object, and with that get the location of the cursor (remember, the cursor is transparent). Then I attempt to get the color of a pixel at the cursor's location.
Where I'm stuck is that it's attempting to get the cursor's color. Is there anyway to get it to see underneath the cursor at the same location?
Thank you all. I've been struggling with this simple problem all week.
public void checkKeyPress() { timer++; if(Greenfoot.isKeyDown("W") && timer >= 10) { setLocation(getX(), getY() + MOVEDISTANCE); ((WorldMap)getWorld().getObjects(WorldMap.class).get(0)).redCheck();
public void redCheck() { Cursor c = ((Cursor)getWorld().getObjects(Cursor.class).get(0)); int cursorX = c.getX(); int cursorY = c.getY(); int red = getImage().getColorAt(cursorX, cursorY - 5).getRed(); System.out.println(red);