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

2014/3/17

Health Bar Help

1
2
hugtvy hugtvy

2014/3/19

#
dont worry i got it working with this simple code haha not quite as good as yours
if (health == 60)
       {
            getWorld().addObject(new Heart(), 283, 27);
            getWorld().addObject(new Heart1(), 232, 27);
            getWorld().addObject(new Heart2(), 179, 27); 
       }
       
        if (health == 40)
       {
           getWorld().removeObjects(getWorld().getObjects(Heart.class));
           getWorld().addObject(new Heart(), 232, 27);
           getWorld().addObject(new Heart(), 179, 27); 
       }
       
        if (health == 20)
       {
           getWorld().removeObjects(getWorld().getObjects(Heart.class));
           getWorld().removeObjects(getWorld().getObjects(Heart1.class));
            getWorld().addObject(new Heart(), 179, 27); 
       }
       
        if (health == 0)
       {
           getWorld().removeObjects(getWorld().getObjects(Heart.class));
           getWorld().removeObjects(getWorld().getObjects(Heart1.class));
           getWorld().removeObjects(getWorld().getObjects(Heart2.class));
       }
     
You need to login to post a reply.
1
2