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

2019/3/15

How can I convert from getObjectsInRange into Actors?

The_bazm The_bazm

2019/3/15

#
.
danpost danpost

2019/3/15

#
The_bazm wrote...
How can I convert from getObjectsInRange into Actors?
Individually:
for (Object obj : getObjectsInRange(/** whatever */))
{
    Actor actor = (Actor) obj;
    // etc.
Each iteration through the loop will have a different in-range actor assigned to actor.
The_bazm The_bazm

2019/3/15

#
Thank you. I have another question: how can i check if an actor belongs to a specific class.
danpost danpost

2019/3/15

#
The_bazm wrote...
Thank you. I have another question: how can i check if an actor belongs to a specific class.
Use the instanceof boolean comparison operator. For examples:
if (getWorld() instanceof Level2)
// or

if (actor instanceof Enemy)
You need to login to post a reply.