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

2015/9/15

rectangle creation

hoothoot hoothoot

2015/9/15

#
sorry I've posted so much about health bars, the only thing I have left to do is have it update while the character loses health. here's my code for the health bar.
 public void fillRect(int x,
            int y,
            int width,
            int height){}
    public void drawRect(int x,
            int y,
            int width,
            int height){}
    private void prepare()
    {
        Cell cell = new Cell();
        int cHlth = cell.getHealth();
        addObject(cell, 600, 390);
        getBackground().fillRect(500, 10, cHlth/300, 30);
    }
this should be the last health bar post
hoothoot hoothoot

2015/9/15

#
I figured out how I would do it, but how do I get a rectangle at its location? let's assume the location is 500, 10. what I'm asking is what do I put in for the third value, so getOneObjectAt(500, 10, ?) what do I put there?
danpost danpost

2015/9/15

#
The two methods, 'fillRect' (lines 1 through 4) and 'drawRect' (lines 5 through 8), are part of the GreenfootImage class. You do not need to put methods with those names in your class. Besides, you are not using those particular methods (the ones in your class) and they both have no implementation (no code to execute when called, just empty brackets, '{}'). It would be best to create the image of the bar and set it to an Actor object placed in your world. Please see my Value Display Tutorial scenario to see how to create a working healthbar.
hoothoot hoothoot

2015/9/15

#
ok
hoothoot hoothoot

2015/9/15

#
thanks
You need to login to post a reply.