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

2012/8/27

progress bar life

isaiasdd isaiasdd

2012/8/27

#
hello, guys ... I'm developing a game with Greenfoot, I'm beginner and would like to create a progress bar of life, but it does not know where to start, could someone give me a light?
SPower SPower

2012/8/27

#
Maybe this scenario by danpost helps: http://www.greenfoot.org/scenarios/4114
Gevater_Tod4711 Gevater_Tod4711

2012/8/29

#
I don't know if I understod you right. You want to create a bar of life and this bar is at the wrong position? In this case you could use the method setLocation(int x, int y). Maybe this webside helps you. Or is your problem that the bar is at the wrong position when your character gets hurt? In this case you should use this:
switch (life) {
    case 1:
        setLocation(anXPosition, anYPosition);
        break;
    case 2:
        setLocation(anXPosition, anYPosition);
        break;
    case 3:
        setLocation(anXPosition, anYPosition);
        break;
    ...
}
Or you trie to paint it with Greenfoot:
//write this at the top above your class declaration
import java.awt.Color;

getImage().clear(); // clears your image;
getImage().scale(x, y) // changes the size of your image;
getImage().setColor(Color.green); // or what Color you'd like to use;
getImage().fillRect(x, y, x2, y2); // makes a green (or other colored) rect. You can change the size to get a different bar.
I hope this will help
You need to login to post a reply.