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

What is happening right now?

Super_Hippo

reply to Accessing variable from other class

By Super_Hippo - about 2 hours ago
You create a new world in line 8 and then get a reference to the new Mario in this new world. Instead, you want a reference to the Mario in the current world. Try to use the 'getWorld' method to get the current world and then, get the Mario from that world. Line also sets the Mario armour variable to the armour variable of the Health_Bar object. One thing is, there is no armour variable in the Health_Bar class (you use it in the 'checkHealth' method, but it isn't created anywhere). The other thing is that you probably want to set the armour used in the Health_Bar to the armour field in this Health_bar (so the other way around). However, I would suggest you remove all code from that class (line 5-34) and add the following methods: <Code Omitted> Whenever the armour variable in the Mario class changes, then you need to get a reference to the Health_Bar object (or you just save a reference in the Mario class), call the 'updateImage' method on the Health_Bar object and pass the new armour value.
Super_Hippo

reply to Making this code easier?

By Super_Hippo - about 2 hours ago
This is what I meant. Not sure if I understood you correctly, though. <Code Omitted> <Code Omitted>
puddle148

reply to For loop to addObjects

By puddle148 - about 6 hours ago
Thanks danpost everything is working now!
Hondrok

reply to Continuity problem

By Hondrok - about 6 hours ago
danpost wrote...
Replace line 94 with the following: <Code Omitted>
thank youu