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

2017/12/5

Lists

CavemanWrath CavemanWrath

2017/12/5

#
How do I call a certain type of actor with a list function? I need both the type and the locations of the 8 surrounding squares to the square that I am checking for, so that I can get my actor to decide its value.
danpost danpost

2017/12/6

#
Use the 'getNeighbours' method in a list iterating for loop -- something like this:
for (Object obj : getNeighbours(getWorld().getCellSize(), Actor.class, true))
{
    Actor actor = (Actor)obj;
    // etc.
You will need to be more specific than getting Actor type objects so that you can perform your check on the actors.
You need to login to post a reply.