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

2020/12/7

Adding a health value that follows the actor and goes down when the actor is hit

Sslur Sslur

2020/12/7

#
Hi, I'm trying to make it so that a health value (int) that follows the actor and goes down depending when he is hit or not. I don't know how to really start it off, so If someone can show me with an example it would be great!
Sslur Sslur

2020/12/7

#
public void followBob() { Bobius bobius = getObjects(Bobius.class).get(0); if (bobius != null) bobHealth.setLocation(bobius.getX(), bobius.getY() - 185); else removeObject(bobHealth); }
danpost danpost

2020/12/7

#
Sslur wrote...
I'm trying to make it so that a health value (int) that follows the actor and goes down depending when he is hit or not. I don't know how to really start it off, so If someone can show me with an example it would be great!
I uploaded a demo for you. It is here.
You need to login to post a reply.