@Peach, the code you are showing gets a new random word and draws the underlines on the world background for each letter in the new word. 'baseX' is assigned the calculated x-coordinate for where the underline for the first letter in the new word is to go. Once that value is determined, the 'for' loop can draw all the underlines for all the letters in the new word in the proper positions so the word is centered along the base of the screen.
@Peach, maybe you are not missing a comma (the comma is so close to the 'j', it appears to be part of the 'j'). Please start a discussion on this issue showing how you are trying to use 'private GreenfootImage getLetterImage("A", java.awt.Color.black)'. Without context it is hard to figure out what you are trying to do.
@Peach, it looks like you are missing a comma between "A" and java.awt.Color.black. And, no, you do not have to have 26 methods, one for each letter. The parameter 'alphaChar' can be any one of the alpha characters that is passed to the 'getLetterImage' method..
As far as the '36', refer to the following link:
http://www.greenfoot.org/files/javadoc/greenfoot/GreenfootImage.html#GreenfootImage(java.lang.String, int, java.awt.Color, java.awt.Color)
All in all, other than the lack of 'return' statements at the end of blocks where 'getWorld().removeObject(this)' is used (which is causing a lot of 'IllegalStateException' throws), the code to this is not bad. The one thing, code-wise, that I did notice was your use of 'getWidth' in the 'paint' method of the world that should be 'getHeight'. The only other thing, which deals with the music, is that some of your sound files have tag information included with is causing ArrayIndexOutOfBoundsException throws. Re-saving the files without the tags should resolve that.
@SullyFish, start a discussion thread, show how you create the bar and how you are trying to use the bar (code posting is better in discussion threads).
@Peach, you are talking about a parameter in the 'getLetterImage' method. '@param' means that the following word is the name of a parameter. 'alphaChar' is the name I gave the String parameter. 'the letter to display on this new image' tells you that the new image created within the method will contain the glyph of the letter contained in the 'alphaChar' string. The calling method, with the expressions for the arguments already evaluated, would look like this:
getLetterImage("L", java.awt.Color.black);
You were asking about declaring a color variable. You declare one just like you declare any other object.
java.awt.Color color = null; // declare variable to hold a color
color = java.awt.Color.blue; // assignment example one
color = new java.awt.Color(255, 64, 40); // assignment example two
If using 'import java.awt.Color;', the previous would be:
Color color = null;
color = Color.blue;
color = new Color(255, 64, 40);
2014/5/19
Hangman
2014/5/19
Hangman
2014/5/17
BGMusic Actor Class Demo
2014/5/16
Hangman
2014/5/16
Hangman
2014/5/15
Side scroll demo
2014/5/14
Progress bar/Health bar class
2014/5/14
Hangman
2014/5/14
Hangman