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

2017/4/7

Healthbar

1
2
Nosson1459 Nosson1459

2017/4/7

#
Nosson1459 wrote...
Change lines 9 - 10 of the X class to:
MyWorld myworld = (MyWorld) getWorld();
I'm not sure if this will actually change anything but it's hard to check with all the myworlds.
Nooooob Nooooob

2017/4/7

#
Nosson1459 wrote...
Nosson1459 wrote...
Change lines 9 - 10 of the X class to:
MyWorld myworld = (MyWorld) getWorld();
I'm not sure if this will actually change anything but it's hard to check with all the myworlds.
No change.
Nosson1459 Nosson1459

2017/4/7

#
Try this in the X class. I'm running out of ideas, if this doesn't either work then there might be something else interfering, so maybe show the Y class code.
MyWorld myWorld = (MyWorld) getWorld();
if (touchingY == false) {
    myWorld.getHealthBar().loseHealth();
    touchingY = true;
    if(myWorld.getHealthBar().health <= 0) {
        getWorld().removeObject(this);
    }
}
Nooooob Nooooob

2017/4/7

#
No difference.
Nosson1459 wrote...
maybe show the Y class code.
So far I put nothing in the Y class.
Nosson1459 Nosson1459

2017/4/7

#
I finally figured out the problem...
Nosson1459 Nosson1459

2017/4/7

#
In your MyWorld class change line 8 to: addObject(healthbar, 50, 10); With getHealthBar() your returning healthbar but that's NOT what has been added into the World, Sorry for all the trouble - my fault.
Nooooob Nooooob

2017/4/7

#
Nosson1459 wrote...
In your MyWorld class change line 8 to: addObject(healthbar, 50, 10);
It's working. Thanks a lot!
Nosson1459 wrote...
Sorry for all the trouble - my fault.
Don't be sorry, thanks for the help :) Tbh I wouldn't have figured it out anytime soon.
You need to login to post a reply.
1
2