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

2014/12/5

Instanceof issue.

ajmetal ajmetal

2014/12/5

#
Im creating a game where a player can use a sword to kill monsters. I want the monsters to each have their own health values and for the player to decrease their health value every time they hit them with a sword. My issue is that all my monsters are created from the same class with one health variable. When that variable reaches 0 they're removed from the world. So if one dies they all die. is there a way I can use instanceof to make this work properly where they each have individual health? or is there a simpler way?
danpost danpost

2014/12/5

#
I am sure there is a simpler way. Post your monster class for assistance (use the 'code' link below the reply box to insert code into your post). Anyway, I do not see how 'instanceof' can help if all the monsters are created from the same class.
You need to login to post a reply.