This site requires JavaScript, please enable it in your browser!
Greenfoot back
Morinator
Morinator wrote ...

2013/10/16

Check any Object is in a Pixel

Morinator Morinator

2013/10/16

#
Hi, I need a method in my World that returns if a certain pixel is occupied with any object. So...i tryed:
public boolean fieldFree(int x, int y)
    {
        if(getObjectsAt(x, y, null)==null)
        {
            return true;
        }
        return false;
    }
but that does not seems to work, please help me :) thank you
SPower SPower

2013/10/16

#
The error isn't here, it's somewhere else. Please show the code related to this.
SPower SPower

2013/10/16

#
Whoops, it should be this:
public boolean fieldFree(int x, int y)  
    {  
        if(getObjectsAt(x, y, null).isEmpty())  
        {  
            return true;  
        }  
        return false;  
    }
because it is a list :)
Morinator Morinator

2013/10/27

#
ty
You need to login to post a reply.