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

2013/3/26

Score Board

JetLennit JetLennit

2013/3/26

#

Score Board

I want to make a score board that shows the score when 1 alien hits the rocket this is the scenario that i want to make this for
danpost danpost

2013/3/26

#
How about getting your score counter working first; then start on the scoreboard.
JetLennit JetLennit

2013/3/26

#
Could you help me do that? the little counter is temporary... i allready got rid of it clientside
danpost danpost

2013/3/26

#
I see you commented out the code within 'bumpCounter'. I do not know why you have a 'setLocation' statement in the 'act' method; in fact, a counter usually will not have an 'act' method. What it does need however, is an int field to hold the counter value and a method to update the image. Here is a (much) modified version of you counter class:
import greenfoot.*;
import java.awt.Color;

public class Counter  extends Actor
{
    private int value;
    
    public Counter()
    {
        updateImage();
    }
    
    private void updateImage()
    {
        setImage(new GreenfootImage(""+value, 20, Color.WHITE, Color.BLACK));
    }

    public void bumpCount(int amount)
    {
        value += amount;
        updateImage();
    }
}
See if you can understand how it works.
JetLennit JetLennit

2013/3/26

#
I understand just fine.. I am not a bad programmer... i am just learning how to get better I cant find out how to call a variable from another class
JetLennit JetLennit

2013/3/26

#
Nevermind about this... i will figure it out on my own
danpost danpost

2013/3/26

#
To add 5 points to the score counter from the Alien class, you can do something like this:
((Counter)getWorld().getObjects(Counter.class).get(0)).bumpCounter(5);
You should probably have a method in the Counter class to retrieve the value of the counter:
public int getValue()
{
    return value;
}
You will need this when it is time to splash the GameOver screen with the final score.
JetLennit JetLennit

2013/3/26

#
Thank you.... but i all ready came up with a way to do it.... if you want to see it you know where to go... but eventually i will probably use that
You need to login to post a reply.