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

2022/12/21

hi

alex90 alex90

2022/12/21

#
i want to make getWorld a static variable but i dont know how. is it even possible?
danpost danpost

2022/12/21

#
alex90 wrote...
i want to make getWorld a static variable but i dont know how. is it even possible?
Why would you want to do that? If for an actor to access a field or method in your world class, you can just typecast what world is returned from using getWorld. Like so:
MyWorld myWorld = (MyWorld)getWorld();
If the actor can be in more than one type of world, you can check its type before typecasting it:
if (getWorld() instanceof MyWorld)
You need to login to post a reply.