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

2017/5/26

Calling a method from the World Class

NickWood18 NickWood18

2017/5/26

#
I am working on the Green foot White blood cell scenario and I am trying to get a score to pop on the screen. In the greenfoot text book is says "We have to call a method from the world class. use getWorld().showText(...); but I am lost on how to call a method from the world class and how to get this method to work. Thanks
danpost danpost

2017/5/26

#
By 'call a method from the World class', I think they mean 'call a method that is defined in the World class'. The 'showText' method is defined in the World class. You can have your World object call it:
1
showText("some text", 100, 20);
or have an Actor object that is in the world call it:
1
getWorld().showText("whatever", 100, 20);
You need to login to post a reply.