Skip to main content
gamedev.net
🔒 Locked

[java] AttributedString -- change text after constructor

Started by Halsafar Oct 13, 2005 at 10:21 PM 2 replies 700+ views
Original Post
Halsafar
Halsafar
AttributedString attStr = new AttributedString("Hello"); Is there anyway I can change the text in the Attributed string without having to create another and set it up.
H_o_p_s
H_o_p_s
Nope.
BRING BACK THE BLACK (or at least something darker)
Halsafar
Halsafar
Hmmm.
Care to suggest an method for drawing player score to the screen. Since that is something which may update lots I don't wish to create a new attStr each time it changes...

H_o_p_s
H_o_p_s
I would just create my own class that displays the score by using g.drawImage()

For instance:
int score;BufferedImage[] numbers = SOME_ARRAY_OF_IMAGES;Char[] characters = String.valueof(score).toCharArray();int offset = 10;for(int i = 0; i < characters.length; i++) {   if(characters=='0') {g.drawImage(numbers[0], SCREEN_WIDTH-offset*i, i, null);}   //repeat for all the characters you want}


or simply use

g.drawString("This is the score: "+score, x,y,null);
BRING BACK THE BLACK (or at least something darker)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.