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

2025/1/16

Information from different classes

MarkusB MarkusB

2025/1/16

#
IT-student here, so far I've always used getOneIntersectingObject to gather information from different objects. But now I have an array as subclass of World and need information about a variable in an actor. I have not found one single comprehensible explaination for that so far. I cannot use the method I'm used to here because those objects don't intersect, can I?
danpost danpost

2025/1/17

#
MarkusB wrote...
IT-student here, so far I've always used getOneIntersectingObject to gather information from different objects. But now I have an array as subclass of World and need information about a variable in an actor. I have not found one single comprehensible explaination for that so far. I cannot use the method I'm used to here because those objects don't intersect, can I?
"an array as subclass of World" makes no sense at all. If you only have one instance of that type actor in the world, then you can use:
ActorType actor = (ActorType) getWorld().getObjects(ActorType.class).get(0);
to get a reference to that actor.
MarkusB MarkusB

2025/1/17

#
What does your code do? I have multiple different actors in my world. Sorry, I don't really know what I'm doing but getting started with stuff like this is super difficult because every slow tutorial is a mess to understand
danpost danpost

2025/1/17

#
MarkusB wrote...
What does your code do? I have multiple different actors in my world. Sorry, I don't really know what I'm doing but getting started with stuff like this is super difficult because every slow tutorial is a mess to understand
Maybe you could show your "array as subclass of World" stuff so we could better understand where you are coming from.
You need to login to post a reply.